score:3
I have been dealing with this issue in a project,this problem is currently an open issue in airbnb react-dates. In order to solve this, I have forked the original project so that it works with jalali moment and the months start from the correct day,the link to the github and npm repositories are:
how to use:
import momentJalali from 'moment-jalaali'
in the constructor of the component in which you want to use datepicker set the appropriate locale :
momentJalali.locale('fa')
import the datepicker from the forked repository:
import {SingleDatePicker,DateRangePicker} from "react-dates-jalali";
in render section use the singdatepicker in the following way:
<SingleDatePicker date={date} //momentDate if you have not set this property,it automatically sets to today focused={this.onFocusChange}//function change focused:open-close onFocusChange={.../function} showClearDate={true} required={true} isRTL={true} monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY' onDateChange={this.onDateChange}//function set your date Change />
in render section use the daterangepicker in the following way:
<DateRangePicker startDate={startDate} //moment startDate if you have not set this property,it automatically sets to today endDate={endDate} //moment endDate onFocusChange={.../function} required={true} isRTL={true} onDatesChange={this.onDatesChange}//function set startDate and endDate focusedInput={focusedInput}//similar to airbnb api-open\close showClearDates={true} monthFormat={monthFormat}//for persian:'jMMMM jYYYY', for english :'MMMM YYYY' />
Needless to say,this repositories support all other airbnb react-dates apis which are not mentioned here.
You can also this repository if your site is multilingual and you can change the locale and month format whenever you want.
score:0
I just imported moment and locale like this and it worked:
import moment from 'moment';
import 'moment/locale/pt-br';
Source: stackoverflow.com
Related Query
- Airbnb react date range picker only showing current month calendar not selected dates month calender
- Airbnb react-dates calendar with non-English locale
- Setting up Airbnb ESLint with React and Webpack
- How to Integrate Google Calendar API with React JS?
- Issue with Semantic ui react calendar
- Multiple events in the same time with react big calendar
- How to redirect react app to non www with htaccess file?
- Material UI select multiple dates with Calendar
- Display multiple dates on React Calendar
- is it possible to mix react jsx with non jsx components?
- React app not loading js file when accessing it with a non home page url
- Making Glyphicon Calendar icon clickable with React JS
- Keyboard navigation on react data grid custom editor with semantic ui calendar date picker
- Using momentjs with correct locale in React server side rendering
- How to append an element to display more text in full calendar event with React js?
- React Day Picker: How to disable interaction with disabled dates in "Select Multiple dates"
- React infinite calendar -- Save multiple dates
- stuck with trying to filter dates in a json object using React
- React JS how do I transform this array of objects with dates and numbers?
- React Calendar with Touch Events
- react redux how to trigger container function with action coming from non react component
- eslint react with airbnb
- React Router with ASP.NET Core Web API 6.0, route all non /api calls to react app
- Prime react dataTable sorting is not working with Dates
- How to make my import react Calendar project english only?
- big calendar react Can we have multiple color on different dates of Month?
- How can i convert my react app from English to Arabic language with the help of a toggle button
- Rerender view on browser resize with React
- Setting a backgroundImage With React Inline Styles
- How to call loading function with React useEffect only once
More Query from same tag
- update data in Mongo DB even when collection does not exist using node.js and mongoose
- React render nested component
- Clickable ticker in React
- ReactJS: Is there a way to see the values used for the key property required for lists
- reactJS useState hook actual value is out dated in async promises
- Search api in node.js
- React.js: How to access URL params in Private Route
- vendors.js: Uncaught TypeError: Cannot read property 'apply' of undefined while using webpack
- How to test for types on react components and props
- Swiper JS / React - is it possible to change the current slide depending on some variable
- How to pass the href value through multiple layers of components in NextJs?
- My React Index.css didn't change any component styling
- Firebase Cloud Function onRequest using CORS not returning return error correctly
- how can I change props of component that pass from higher component . reactjs
- Multi attach Laravel from ReactJS
- Reactjs `openAlertAbsent` is not a function
- HOC Redux Dispatch gets called after child component calls React componentDidMount
- React state not getting updated in function call
- React.js inserting multiple states into one main state
- Warning: React does not recognize the `FirstName` prop on a DOM element
- React Hook useState returns undefined for props value but props value appears on textbox value
- How to select parent components variant in styled components?
- ReactJS - Call parent method from child component and await response from parent
- netlify deployment: Failed during stage 'building site': Build script returned non-zero exit code: 2
- How to test this statement using jest and enzyme
- styled components server and client mismatch when importing from a yarn workspaces common package
- Cannot call `bindActionCreators` because `Action` [1] is incompatible with `ActionCreator`
- React fetch every url of an array of urls in a json
- React - Navbar not showing and I am getting a Blank Screen
- Iam trying to update the state "Experience" but I didn't get updated value. please correct if my code is wrong