I am new to reactjs and want to know if there is a way to check if the state value is datetime in reactjs.
What i am trying to do?
On clicking the checkbox i set its state to current date and time. But its value is not updating meaning after clicking submit button it doesnt update the checkbox....the checkbox isnot checked even though user checks it. How do i check if the value of the variable is datetime. Below is the code...Could someone help me with this. Thanks.
class Name extends React.PureComponent {
constructor(props) {
super(props);
const topic = props.topic;
this.state = {
checkbox_checked: some_value ? some_value.property : null,
};
}
handle_checkbox_change = (event) => {
this.setState({'checbox_checked': (event.target.checked === true ? timeUtils.date_to_iso_format(new Date()) : null)}, () => console.log('checkbox status:', this.state.checkbox_checked));
};
render () {
return (
<input
name="checkbox_name"
checked={state.resolved}
onChange={this.handle_checkbox_change}
type="checkbox"/>
<span>Checkbox</span>
<button type="submit">
</button>);}}