score:0
did you bind the onchange method in your constructor? like so:
constructor(props) {
super(props);
this.onchange = this.onchange.bind(this);
}
i stripped out some of the other stuff to just focus on the event binding. here's also a bigger breakdown of forms and such through their documentation: https://reactjs.org/docs/forms.html
also, this is super nitpicky, but handlechange would be more semantic than onchange for this type of situation.
score:1
when you want to pass parameters to the function you have to bind or call a callback function!
onchange={this.onchange} //wrong way
the solution is:
onchange={() => this.onchange(date)} //the most used way!
or
onchange={this.onchange.bind(this,date)}
one of them should work for you !
Source: stackoverflow.com
Related Query
- React onChange Method not changing state of object
- State in React not changing with setState method
- Not able to target a sub property of a JSON object in react stored in state within the render method
- React js State Object is not recognized within the render method
- onChange is not working in react functional component while changing the value through state update
- onChange on React componet not changing state inside it's parent
- React not re-rendering on changing array within state object
- Why does calling react setState method not mutate the state immediately?
- React changing props on grandchildren: object is not extensible / tree traversing react children
- React js changing state does not update component
- Changing object property in an array with React Hooks does not evoke a re-render
- React not updating state with setState with Array of object
- React setState not changing state of particular property
- useState set method not changing the value - React
- React <Switch> is not getting updated or changing its state
- Method not getting correct useState value despite updating state in React
- react state extend multilevel object not working
- Changing state but not rerendering react redux
- React select onChange not changing selected value
- React ui not updating although i'm changing the state
- React setState not changing the state
- React DnD useDrop is not using the current state when the method is called
- Why does react component do not re render after changing state
- React JS is not changing state after event inside FileReader
- React state changing when pushing nested object
- React state not changing on button click
- React using method parameter as an object key to update state
- Using a global object in React Context that is not related to state
- Why is my react state not changing properly?
- React table sorting is not consistent its keep changing back to default state
More Query from same tag
- setState not working in componentDidMount() - React
- React Hooks : mapping data from api call to render pie chart
- Svg animations not running on Safari
- How to understand the logic of Gatsby blog template content types?
- Rendering 2 navbar
- Meteor: accounts-ui Package
- What ref tag do I use for draft.js?
- Showing a value (instead of label) on a Material UI Autocomplete
- Loading json data with Fetch to pass it to React Component as prop
- Redux reducer function not working. State remains undefined
- How to allow <input type="file"> to accept only Lottie files?
- Cannot get prevState from componentDidUpdate lifecycle hook in React.js v18.1.0
- Downloading From Amazon S3 Bucket with a file name
- Robust way to handle app errors inside mapStateToProps?
- How should I organize my application?
- Transforming the value of an object from string to number
- Avoid re-render while open/close material-ui Dialog component
- How to send array of objects data from child component to parent component and store in the parent object using react hooks?
- React - How to hide register/login in navbar once a user has logged in?
- React proxy not conecting to api url
- How to show different icon in active NavLink in react-router-dom v6?
- How can I disable/enable the button based on multiple checkboxes state in React.js
- A mistake causes the function to be rendered infinity
- React - toggle only one button, not all
- How do I do a set timer within each react component?
- Force refresh REACTjs application the same way as ctrl+F5
- next/image loads very big images
- Material UI: Is it possible to put the makeStyle styles in a separate file?
- Redirect To Route within Function React Router Dom
- Where to have the socket object in your redux app?