Skip to content

Commit ee3e6e8

Browse files
committed
Document @:state
1 parent c8a2e6f commit ee3e6e8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class Button extends Component {
3737
</button>
3838
';
3939
40+
@:story
41+
@:state(var value:Int = 0) // add state to a story
42+
function withState() '
43+
<button onclick=${value += 1}>
44+
Clicked ${value} time(s)
45+
</button>
46+
';
47+
4048
function wrap(f:()->ReactSingleFragment) '
4149
<div style=${{backgroundColor: 'black'}}>${f()}</div>
4250
';

src/coconut/storybook/Setup.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Setup {
1717
for (field in builder)
1818
switch [field.kind, field.metaNamed(':story'), field.metaNamed(':state')] {
1919
case [FFun(func), stories, v] if (stories.length > 0):
20-
// wrap with Isolated
20+
// wrap with Isolated, so changes will trigger re-render
2121
function subst(e:Expr)
2222
return switch e {
2323
case macro return $ret:

0 commit comments

Comments
 (0)