Skip to content

Commit

Permalink
Document @:state
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinresol committed May 28, 2020
1 parent c8a2e6f commit ee3e6e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class Button extends Component {
</button>
';
@:story
@:state(var value:Int = 0) // add state to a story
function withState() '
<button onclick=${value += 1}>
Clicked ${value} time(s)
</button>
';
function wrap(f:()->ReactSingleFragment) '
<div style=${{backgroundColor: 'black'}}>${f()}</div>
';
Expand Down
2 changes: 1 addition & 1 deletion src/coconut/storybook/Setup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Setup {
for (field in builder)
switch [field.kind, field.metaNamed(':story'), field.metaNamed(':state')] {
case [FFun(func), stories, v] if (stories.length > 0):
// wrap with Isolated
// wrap with Isolated, so changes will trigger re-render
function subst(e:Expr)
return switch e {
case macro return $ret:
Expand Down

0 comments on commit ee3e6e8

Please sign in to comment.