File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
A simple ` React.useState ` sugar based on js label
4
4
5
+ just for fun :) 😄
6
+
5
7
### Quick Start
6
- 1⃣️ install
7
- ```
8
+ ``` sh
9
+ # install
8
10
npm install --save-dev babel-plugin-react-label-sugar
9
11
```
10
12
11
- 2⃣️ add plugin in .babelrc
13
+ Add plugin in .babelrc
12
14
``` json
13
15
{
14
16
"plugins" : [" babel-plugin-react-label-sugar" ]
15
17
}
16
18
```
17
19
18
- 3⃣️ (optional) custom options
20
+ (optional) custom options
19
21
``` json5
20
22
{
21
23
" refLabel" : " $" , // default is "ref"
@@ -54,11 +56,11 @@ $: student = { name: "xyy" };
54
56
55
57
_ ** Work with immer** _
56
58
57
- 1⃣️ set ` ignoreMemberExpr ` to be ` true ` in ` .babelrc `
59
+ Set ` ignoreMemberExpr ` to be ` true ` in ` .babelrc `
58
60
59
- 2⃣️ set ` refFactory ` to be ` useImmer ` in ` .babelrc `
61
+ Set ` refFactory ` to be ` useImmer ` in ` .babelrc `
60
62
61
- 3⃣️ install and import ` useImmer ` in your code
63
+ Install and import ` useImmer ` in your code
62
64
63
65
``` jsx
64
66
// before
@@ -72,7 +74,3 @@ setObj((obj) => { obj.count++ });
72
74
73
75
### Todo List
74
76
- [x] support useImmer, transpile ` obj.value = 1 ` to ` setObject(obj => obj.value = 1) `
75
-
76
- ### But why?
77
-
78
- just for fun :) 😄
You can’t perform that action at this time.
0 commit comments