This repository was archived by the owner on Mar 16, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
src/docs/documentation/general Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,51 @@ This can be very useful to test and develop your components in a good environmen
4343
4444Note that you can edit the code below the components from your browser and see the changes you make be reflected live above it!
4545
46+ ### Stateful components
47+
48+ The ` <Playground> ` component is also able to let you edit stateful and functional components:
49+
50+ ``` jsx
51+ import { Playground } from ' docz'
52+
53+ # Counter
54+
55+ < Playground>
56+ {() => {
57+ const [counter , setCounter ] = React .useState (0 )
58+ return (
59+ <>
60+ < button onClick= {() => setCounter (counter => counter+ 1 )}>
61+ Increase
62+ < / button>
63+ < p> {counter}< / p>
64+ < / >
65+ )
66+ }}
67+ < / Playground>
68+ ```
69+
70+ If you wrap the previous render inside a separate ` <Counter> ` component, it becomes:
71+
72+ ``` jsx
73+ import { Playground } from ' docz'
74+ import { Counter } from ' ./Counter'
75+
76+ # Counter
77+
78+ < Playground>
79+ {() => {
80+ const [counter , setCounter ] = React .useState (0 )
81+ return (
82+ < Counter
83+ value= {counter}
84+ onChange= {() => setCounter (counter => counter+ 1 )}
85+ / >
86+ )
87+ }}
88+ < / Playground>
89+ ```
90+
4691## Component Props
4792
4893One of the most important things when documenting a component is to know which props it expects.
You can’t perform that action at this time.
0 commit comments