score:0
it seems to me that you do not need new instance of moment when you pass data to mindate prop. you are doing it like this mindate={ new moment(this.props.mindate)}
.
react-datepicker already internally uses moment for manipulating data objects so i think you should just remove keyword new in front of a moment when you are passing it to the mindate prop.
score:0
i figure this one myself, it appears that if selected
property is set, it will shown and not the mindate
property.
score:1
i think you have to give value for this, because mindate and maxdate are for validation purpose. mindate will only be the resulting value only if, when given value or current date is less then min date
class example extends react.component {
constructor (props) {
super(props)
this.mindate = new moment(props.mindate)
this.state = {
startdate: props.mindate
};
this.handlechange = this.handlechange.bind(this);
}
handlechange(date) {
this.setstate({
startdate: date
});
}
render() {
return <datepicker
selected={this.state.startdate}
onchange={this.handlechange}
mindate={this.mindate}
value={this.props.startdate}
/>;
}
}
Source: stackoverflow.com
Related Query
- react-datepicker fails with moment and new Date
- Formatting date and time using Moment with React JS
- How to test snapshots with Jest and new React lazy 16.6 API
- onEnter Transitions with React Router and Redux Simple Router Dont Render New Route's Component
- Min and Max Date in Material UI DatePicker in React
- React datepicker set min and max date
- New React project 2.1 fails with NPM ERR! 418 I'm a teapot
- How to find most recent date from an array of object then add new field and return array in react
- Heroku deploy fails with react and next js
- SonarQube with Jest and react - Coverage on 0 New Lines to cover
- Invalid Date in edit form on birthday field using React JS and moment
- React Router Link with params not reloading page with new data from componentDidMount and Redux axios data fetching
- validate date with Moment in React
- How can I make react render the new state modifications after I have updated the state with hooks and context
- Testing react component with enzyme and expect fails
- React Hook Form with datepicker Range doesn't pick date
- React Date Picker and Moment
- How to format get and format Date in DatePicker in Material UI React
- how to store textarea new line value into array with react and send it to node js variable with post request
- React router - click on card and redirect to a new page with content of that card (card details) using useParams and reacthooks
- React router - click on card and redirect to a new page with content of that card (card details)
- React Antd DatePicker with custom format for input and for display
- How to click a button and navigate to a new route with URL params using React Router 4
- How to create a new page and route programatically in React.js with React Router
- set and get date and time in localStorage in react datepicker
- React - change props at child1 with callback and pass new value to child2
- React looping and creating new array with nested objects
- React Hooks useEffect saves the last state and won't update it with the new one. It runs twice with two different states
- React material-ui and reactstrap form inline with button new line
- Error with new Set in typescript and react
More Query from same tag
- React & Redux - state getting empty after route changed
- A better way to handle updating state in reducer
- Problem showing global spinner using redux and react
- How can I see enlarged image when I click on the actual img
- JS / JSX function always returns true even if it's false
- Dynamic JSX element/tag names
- React Route path not generating desired component
- Success message continues fire despite error state in Semantic-React-UI form
- index.js:1 Warning: Failed prop type: Invalid prop `src` of type `object` supplied to `ForwardRef(Avatar)`, expected `string`
- React - Children Accessing Parents state too early?
- Image is not shown in nested curly braces in react js functional component
- Filter array using regex in React.js?
- React | How can i display my image in React?
- how to get data into an array after post using axios in reactjs
- How to solve React "too many re-renders" error
- React CORS error occurs when integrating with graphQL
- Allow a stateless function to accept multiple different prop interfaces
- Updating React state after Finished Rendering
- Rendering a table where each cell correspond to an element with material-ui in React.js
- React Redux and React Router connect
- React Router renders two components instead of one
- Passing props via <Link> tag to separate page
- How do I update an array for a React component?
- React is not binding function call despite warnings to the contrary
- Return a React Component From a Function and Give it Props
- Learning ReactJS: Uncaught SyntaxError: Unexpected token import
- How to add padding and margin to all Material-UI components?
- Component event handler receiving props of different component in list
- Trigger useEffect hook when only one element in an array change
- TypeError: Cannot read property 'length' of undefined in react