Created
January 6, 2018 06:18
-
-
Save mezzode/ce153dbeb45e54bb5b7657684d7d391f to your computer and use it in GitHub Desktop.
ReasonReact with Storybook
This file contains 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
/* src/page.re */ | |
let component = ReasonReact.statelessComponent("Page"); | |
let handleClick = (_event, _self) => Js.log("clicked!"); | |
let make = (~message, _children) => { | |
...component, | |
render: (self) => | |
<div onClick=(self.handle(handleClick))> | |
(ReasonReact.stringToElement(message)) | |
</div> | |
}; | |
let page = ReasonReact.wrapReasonForJs( | |
~component, | |
(jsProps) => make(~message=jsProps##message, [||]) | |
); | |
let default = page; |
This file contains 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
// stories/page.stories.js | |
import React from 'react'; | |
import { storiesOf } from '@storybook/react'; | |
// exported using `let default = ...` | |
import Page from '../src/page.bs'; | |
// exported using `let page = ...` | |
import { page as OtherPage } from '../src/page.bs'; | |
storiesOf('Page', module) | |
.add('Moo', () => <Page message="Moo" />); | |
storiesOf('OtherPage', module) | |
.add('Moo2', () => <OtherPage message="Moo2" />); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment