Skip to content

Instantly share code, notes, and snippets.

@mlms13
Created March 24, 2019 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlms13/933c2c9c0b3630fc5a82664dc03d8c15 to your computer and use it in GitHub Desktop.
Save mlms13/933c2c9c0b3630fc5a82664dc03d8c15 to your computer and use it in GitHub Desktop.
[@bs.module "react-native-calendario"]
external calendar: ReasonReact.reactClass = "default";
type dateRange = {
startDate: Js.Date.t,
endDate: option(Js.Date.t),
};
let dateRangeFromJS = range => {
startDate: range##startDate,
endDate: Js.Nullable.toOption(range##endDate),
};
let make =
(
~startDate: option(string)=?,
~endDate: option(string)=?,
~onChange: option(dateRange => unit)=?,
children,
) =>
ReasonReact.wrapJsForReason(
~reactClass=calendar,
~props=
Js.Nullable.{
"startDate": startDate->fromOption,
"endDate": endDate->fromOption,
"onChange":
onChange
->Belt.Option.map((fn, range) => dateRangeFromJS(range)->fn)
->fromOption,
},
children,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment