Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteXyy committed Nov 12, 2020
1 parent 2753991 commit 9d1c244
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

A simple `React.useState` sugar based on js label

just for fun :) 😄

### Quick Start
1⃣️ install
```
```sh
# install
npm install --save-dev babel-plugin-react-label-sugar
```

2⃣️ add plugin in .babelrc
Add plugin in .babelrc
```json
{
"plugins": ["babel-plugin-react-label-sugar"]
}
```

3⃣️ (optional) custom options
(optional) custom options
```json5
{
"refLabel": "$", // default is "ref"
Expand Down Expand Up @@ -54,11 +56,11 @@ $: student = { name: "xyy" };

_**Work with immer**_

1⃣️ set `ignoreMemberExpr` to be `true` in `.babelrc`
Set `ignoreMemberExpr` to be `true` in `.babelrc`

2⃣️ set `refFactory` to be `useImmer` in `.babelrc`
Set `refFactory` to be `useImmer` in `.babelrc`

3⃣️ install and import `useImmer` in your code
Install and import `useImmer` in your code

```jsx
// before
Expand All @@ -72,7 +74,3 @@ setObj((obj) => { obj.count++ });

### Todo List
- [x] support useImmer, transpile `obj.value = 1` to `setObject(obj => obj.value = 1)`

### But why?

just for fun :) 😄

0 comments on commit 9d1c244

Please sign in to comment.