File tree Expand file tree Collapse file tree 1 file changed +42
-2
lines changed Expand file tree Collapse file tree 1 file changed +42
-2
lines changed Original file line number Diff line number Diff line change 44
55[ ![ Test] ( https://github.com/barelyhuman/babel-transform-mutable-react-state/actions/workflows/test.yml/badge.svg )] ( https://github.com/barelyhuman/babel-transform-mutable-react-state/actions/workflows/test.yml )
66
7+ ** UNSTABLE**
8+ ** The plugin is still under development so isn't recommended for production**
9+
710## Install
811
912TBD
1013
1114## Usage
1215
13- ** UNSTABLE**
14- The plugin is still under development so isn't recommended for production
16+ You write state with a prefix ` $ ` and that's converted to ` useState ` accordingly.
17+
18+ ``` jsx
19+ import * as React from ' react'
20+
21+ function Component () {
22+ let $a = 1
23+
24+ const onPress = () => {
25+ $a += 1
26+ }
27+
28+ return (
29+ < div>
30+ < p> {$a}< / p>
31+ < button onClick= {onPress}> Press< / button>
32+ < / div>
33+ )
34+ }
35+ ```
36+
37+ ``` jsx
38+ import * as React from ' react'
39+
40+ function Component () {
41+ const [a , setA ] = React .useState (1 )
42+
43+ const onPress = () => {
44+ setA (a + 1 )
45+ }
46+
47+ return (
48+ < div>
49+ < p> {a}< / p>
50+ < button onClick= {onPress}> Press< / button>
51+ < / div>
52+ )
53+ }
54+ ```
1555
1656## License
1757
You can’t perform that action at this time.
0 commit comments