Comments (16)
Did you try to use useConfirm(...) in child component? I can see it happening when you're wrapping component in and use useConfirm(...) in the same component.
from material-ui-confirm.
Ok I got it . I Wrapped Autocomplete in ConfirmProvider but it is too deep. Thanks. A great work with material-ui-confirm :)
from material-ui-confirm.
Did you wrap the whole app component tree in ConfirmProvider
?
from material-ui-confirm.
Yes, I am using MuiThemeProvider and originally had ConfirmProvider as a child. However, I removed MuiThemeProvider ensuring ConfirmProvider was outermost and still the same issue.
from material-ui-confirm.
And I assume you are calling useConfirm
in a functional component in that component tree? Seems weird, are there any significant differences between your usage and the demo?
from material-ui-confirm.
I am. I don't see anything very different from the samples.
from material-ui-confirm.
I guess one somewhat significant difference is my app is typescript.
from material-ui-confirm.
I see, I don't have any other ideas for why it wouldn't work without some kind of reproduction : <
from material-ui-confirm.
@KarolError404 thanks for that pointer—this is what I was doing to run into this. Perhaps this could be more clear in the docs?
from material-ui-confirm.
That's generally the case for the context provider + hooks pattern, common in many packages. I added a tiny clarification to the readme (043ccd4).
@gardengeek99 does this match your case?
from material-ui-confirm.
Yes that’s helpful for someone like me who is still new to React, thank you!
from material-ui-confirm.
Hi I ave the same issue: undefined confirm.
import { useConfirm, ConfirmProvider } from 'material-ui-confirm';
export default function TagTextForm({label, placeholder, onChange}) {
const classes = useStyles();
const confirm = useConfirm();
console.log(confirm) //undefined
const handleChange = (ev, value, reason) => {
console.log("confirm", confirm) //undefined
}
return (
<div className={classes.root}>
<ConfirmProvider>
<Autocomplete
multiple
id="tags-text"
onChange={(ev, value, reason) =>
....
/>
</ConfirmProvider>
</div>
);
}
What I am doing wrong?
from material-ui-confirm.
@atompie the TagTextForm
component needs to itself be wrapped in ConfirmProvider
. Generally you want to keep ConfirmProvider
at the very top level in the App
component, similarly to router, theme provider, etc.
from material-ui-confirm.
Since there is no reproduction, I'm going to close this for now.
from material-ui-confirm.
I had this issue too:
- In my Next.js project it worked great
- In my Storybook wrapping my stories with the general decorator was not working with
ConfirmProvider
whereas all my other providers work great
My "workaround" is to set the wrapper component in another file then to use it inside preview.jsx
. I can't explain why... hope this helps!
from material-ui-confirm.
Interesting, it does work for the stories in this repo:
material-ui-confirm/stories/index.stories.js
Lines 210 to 212 in 4cb9a10
from material-ui-confirm.
Related Issues (20)
- Feature request: cancel without rejecting Promise HOT 1
- The button props for color not working properly. HOT 4
- Change the order of buttons HOT 3
- How to handle confirmed action result to stay and display an error? HOT 2
- Closing the confirm should reject the promise HOT 6
- package this library also as UMD HOT 1
- Can't hide Cancel button HOT 4
- What version should I use for MUI v4? HOT 1
- Suggestion - add result in promise HOT 4
- Q: how to add form fields + read them after OK is pressed? HOT 1
- Button onclick event HOT 1
- Providing a Static Method for Easy Use Without Hooks, Suitable for Class Component Projects HOT 3
- Asynchrounous Confirm Suggestion HOT 1
- Allow `data-attributes` on `dialogProps` HOT 1
- The input value remains in the TextField even after the dialog is closed. HOT 2
- Feat: Add an acknowledge checkbox HOT 2
- Executing navigate in the then method may result in confirm not disappearing。 HOT 2
- How to close the confirm dialog programmatically? HOT 6
- v3.0.13 removes react 17 support due useId inclusion HOT 1
- Flash of default dialog content during close HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui-confirm.