react-use-modal | A react component for manage modal | Frontend Utils library
kandi X-RAY | react-use-modal Summary
kandi X-RAY | react-use-modal Summary
A react component for manage modal
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 react-use-modal
react-use-modal Key Features
react-use-modal Examples and Code Snippets
Community Discussions
Trending Discussions on react-use-modal
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 react-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