Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Hooks #2

Closed
Cristy94 opened this issue Jan 9, 2020 · 3 comments
Closed

Usage with Hooks #2

Cristy94 opened this issue Jan 9, 2020 · 3 comments

Comments

@Cristy94
Copy link

Cristy94 commented Jan 9, 2020

Can material-ui-confirm used in functional components?

Why is withConfirm needed? Can't there just be a global "confirm" function?

@jonatanklosko
Copy link
Owner

It sure can, the example in README actually shows a functional component.

withConfirm is just a higher order component that is used to add a dialog alongside the wrapped component and open it whenever you call the confirm function added to the wrapped component props.

I do however plan to play around with turning this into hooks-based version that would require adding a context provider once and using const confirm = useConfirm(); whenever needed;

@jonatanklosko
Copy link
Owner

I've just released v2, which makes full use of hooks! It's definitely cleaner and more flexible now.

@Cristy94
Copy link
Author

Nice, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants