Skip to content

Commit 4981c3b

Browse files
authored
Update README.md
1 parent 0a16cda commit 4981c3b

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,46 @@
99

1010
## Caveats (for now)
1111

12-
- Doesn't support pragma right now
13-
- Update Expressions aren't supported (eg: variableName++) on numbers won't work.
12+
Check [this issue](https://github.com/barelyhuman/babel-plugin-mutable-react-state/issues/4)
13+
14+
15+
## Notes
16+
- While the caveats exist due to the extensive types of expressions that javascript has, it's recommended that you use a cloned variable and then just assigned the modification to the reactive variable if you plan to use it right now.
17+
```jsx
18+
19+
function Component(){
20+
let $text = "";
21+
22+
return <>
23+
<input value={$text} onChange={e=> {
24+
$text = e.target.value;
25+
// some code
26+
27+
// won't work...
28+
$text = $text.toUpperCase()
29+
}}/>
30+
</>
31+
}
32+
33+
// CAN be written as
34+
35+
function Component(){
36+
let $text = "";
37+
38+
return <>
39+
<input value={$text} onChange={e=> {
40+
const val = e.target.value;
41+
// some code
42+
43+
// will work...
44+
$text = val.toUpperCase()
45+
}}/>
46+
</>
47+
}
48+
49+
```
50+
51+
1452

1553
## Install
1654

0 commit comments

Comments
 (0)