react-form-with-constraints | Simple form validation for React | Validation library
kandi X-RAY | react-form-with-constraints Summary
kandi X-RAY | react-form-with-constraints Summary
️ Client side validation is cosmetic, you should not rely on it to enforce security. The required HTML5 attribute specifies that the user must fill in a value, type="email" checks that the entered text looks like an email address.
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-form-with-constraints
react-form-with-constraints Key Features
react-form-with-constraints Examples and Code Snippets
Community Discussions
Trending Discussions on react-form-with-constraints
QUESTION
I have created a timer module from react in which there is one input and three button 1-Start(which starts the timer) 2-Pause(pause the timer) 3-Stop(Stops the timer), Now the problem is that when i input any value and starts the timer and when i press "Stop" button the value becomes 0 but when i again hit the "Start" button the counter starts from the previous value which i clicked at the time of Stop button rather it should start from the value which is written on input field previously. Please check it if you are not understanding what i'm telling.
Code:
...ANSWER
Answered 2017-Sep-26 at 13:46All your code is almost fine, but you need to make some changes to make it work correctly as you expected.
So first, you need to save the last input (number) for the countdown, so let's add lastInput: 0
into your component's state, that state will be filled when your type some number in the input field, so each time you type the lastInput
property will change with the value that you set.
Once you have clicked on Stop button, you were doing only this: this.setState({ count: 0 })
but you were forgetting something else, you need to restart the property customNumber
too to reset it, so you need to do this: this.setState({ count: 0, customNumber: this.state.lastInput })
where this.state.lastInput
has the last value set by the user, that is for avoid to save the input's value into a local variable, so I think it's better to save that value into the component state.
NOTE
If you are using babel in your React component, it will be better using arrow function from ES6, so you can avoid the this.myfunction.bind(this)
syntax so you could do it in this way:
taking your code as example it would be like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-form-with-constraints
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