Created
March 24, 2019 03:51
-
-
Save mlms13/933c2c9c0b3630fc5a82664dc03d8c15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[@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