react-mobile-datepicker | look a demo , Please imitate mobile environment | Mobile library
kandi X-RAY | react-mobile-datepicker Summary
kandi X-RAY | react-mobile-datepicker Summary
look a demo, Please imitate mobile environment.
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-mobile-datepicker
react-mobile-datepicker Key Features
react-mobile-datepicker Examples and Code Snippets
Community Discussions
Trending Discussions on react-mobile-datepicker
QUESTION
In my code, was trying to render a in
component of Redux Form, via a function called
renderDatePicker()
. This function is linked to handleClick()
function where the state variable isOpen
is set to true
.
So ideally, onClick
should render the as it is set to visible. But code doesn't update anything. Where am I doing wrong here?
Note: Rendering alone directly without the help of
, works fine.
For debugging, complete code is in CodeSandbox,
SimpleForm.js
...ANSWER
Answered 2019-Aug-08 at 13:42The reason for this behavior lies in the implementation of react-form's Field
component. It does a shallow compare of all its properties to decide whether it should rerender. You can change your component's state
as much as you like, the reference to this.renderDatePicker
won't change.
Field
passes properties including an onChange
handler and the current value
into the field's component
stateless function call to notify of changes, but this doesn't really apply here because your toggle button is outside of the field.
So one option that comes to my mind is to move your button into the rendered field and then call onChange(!value)
.
The easier yet dirtier option would be to use an arrow function in your component
property: component={() => this.renderDatePicker()}
- this instance changes with every re-render of your SimpleForm
(i.e. if the state
changes), so it comes with a cost, but depending on the complexity of your application the cost is negligible. To mitigate the impact, you could implement shouldComponentUpdate
(just like redux-form's Field
does) to decide whether it should rerender or not, based on the current and next isOpen
state.
Check this bit in redux-form for more details: https://github.com/erikras/redux-form/blob/master/src/createField.js#L44
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-mobile-datepicker
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