diff --git a/docs-site/src/example_components.jsx b/docs-site/src/example_components.jsx index 8b6f86621..321d1d77d 100644 --- a/docs-site/src/example_components.jsx +++ b/docs-site/src/example_components.jsx @@ -10,6 +10,7 @@ import CustomDayClassNames from "./examples/custom_day_class_names"; import PlaceholderText from "./examples/placeholder_text"; import SpecificDateRange from "./examples/specific_date_range"; import Locale from "./examples/locale"; +import LocaleWithoutGlobalVariable from "./examples/locale_without_global_variable"; import ExcludeDates from "./examples/exclude_dates"; import HighlightDates from "./examples/highlight_dates"; import HighlightDatesRanges from "./examples/highlight_dates_with_ranges"; @@ -125,6 +126,10 @@ export default class exampleComponents extends React.Component { title: "Locale", component: }, + { + title: "Locale without global variables", + component: + }, { title: "Exclude dates", component: diff --git a/docs-site/src/examples/locale_without_global_variable.jsx b/docs-site/src/examples/locale_without_global_variable.jsx new file mode 100644 index 000000000..4d265bac0 --- /dev/null +++ b/docs-site/src/examples/locale_without_global_variable.jsx @@ -0,0 +1,57 @@ +import React from "react"; +import DatePicker, { registerLocale } from "react-datepicker"; +import fi from "date-fns/locale/fi"; + +export default class LocaleWithoutGlobalVariable extends React.Component { + state = { + startDate: null + }; + + handleChange = date => { + this.setState({ + startDate: date + }); + }; + + render() { + return ( +
+
+          
+            {
+              "// Note: Make sure to npm install the right version of date-fns as"
+            }
+            
+ { + "// specified in packaged.json. The default one may not be compatiable" + } +
+ {"// npm install --save date-fns@version"} +
+ {"import DatePicker from 'react-datepicker';"} +
+ {"import fi from 'date-fns/locale/fi';"} +
+
+ {" + {" selected={this.state.startDate}"} +
+ {" onChange={this.handleChange}"} +
+ {" locale={fi}"} +
+ {"/>"} +
+
+
+ +
+
+ ); + } +}