use-modal | React hook for easy work with modals | Frontend Utils library
kandi X-RAY | use-modal Summary
kandi X-RAY | use-modal Summary
React hook for easy work with modals
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of use-modal
use-modal Key Features
use-modal Examples and Code Snippets
Community Discussions
Trending Discussions on use-modal
QUESTION
In my Angular 4 app, let's assume that I'm inside a service.
At some point I want to ask to the user for a confirmation, currently I'm doing it with just a confirm(...)
request:
const result = confirm('Are you sure?');
what if instead I would like to show a ngx-bootstrap
modal with, let's say, two buttons "Yes" or "No" and obtain a similar result?
EDIT: in my case, I solved my issue by playing with Subjects. Here you can find my solution, in case it can be useful for someone else. However that solution does not solve this question which is about returning a value from a modal, so I leave it open.
...ANSWER
Answered 2017-Sep-25 at 17:32Try like this :
myexample it's working correctly. hope this will help you
home.module.ts
QUESTION
I use the library react-use-modal
, and
I'm trying to read the updated value of confirmLoading
when inside the handleClick
function.
handleClick
does read the first value of confirmLoading
defined when doing const [ confirmLoading, setConfirmLoading ] = useState(false)
, but never updates when I setConfirmLoading
inside handleOk
.
I don't understand what I'm doing wrong
...ANSWER
Answered 2019-May-08 at 17:10This is happening because of closures. The component that you pass to showModal
remembers confirmLoading
and when you call function setConfirmLoading
your component renders again and function handleClick
is recreated. 'Old' handleClick
and 'old' component in showModal
know nothing about the new value in confirmLoading
.
Try to do this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install use-modal
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page