For example, we want the use of moment.js inside our REASONML code.
What we can does is create a module file:
// moment.re = = TT = "moment" and "= String =" "[@ @bs. send];
Using It inside Component:
/*This is the basic component.*/Let component= reasonreact.statelesscomponent "Page";/*Your familiar Handleclick from Reactjs. This mandatorily takes the payload, then the "Self" record, which contains state (none here), ' handle ', ' reduce ' and O Ther Utilities*/Let handleclick _event _self= = Js.log "clicked!"; Let momentnow = moment.momentwithdate (Js.Date.make ()); /*' make ' was the function that mandatorily takes ' children ' (if you want to use ' JSX '). ' Message ' is a named argument, Which simulates reactjs props. Usage: ' <page message= ' hello '/> ' which desugars to ' reasonreact.element (Page.make message:: "Hello" [| |]) ` */Let make :: Message:: Times _children={... component, render:fun self= <div onclick= (self.handle handleclick) >( reasonreact.stringtoelement message) (reasonreact.stringtoelement times) (reasonreact.stringtoelemen T (Moment.format momentnow "dddd")) </div>};
[REASONML] Using Javascript NPM Package from REASON