Skip to content

Commit 4a033bf

Browse files
committed
chore: update readme to the new version
1 parent 385739a commit 4a033bf

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ $ git clone https://github.com/pedronauck/reworm
1212
$ yarn install
1313
```
1414

15-
Keep in mind that after running `yarn install` the git repo is reset. So a good way to cope with this is to have a copy of the folder to push the changes, and the other to try them.
16-
1715
Make and commit your changes. Make sure the commands `yarn build` and `yarn test:prod` are working.
1816

1917
Finally send a [GitHub Pull Request](https://github.com/pedronauck/reworm/compare?expand=1) with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).

README.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</p>
1111

1212
<p align="center">
13-
<img src="https://cdn-std.dprcdn.net/files/acc_649651/UtUFi5" width="80%"/>
13+
<img src="https://cdn-std.dprcdn.net/files/acc_649651/HkXs48" width="80%"/>
1414
</p>
1515

1616
## 🧐 &nbsp; Why?
@@ -31,12 +31,10 @@ Then just create your new state and use it!
3131
import React from 'react'
3232
import { create } from 'reworm'
3333

34-
const { State, get } = create({ name: 'John' })
34+
const { get } = create({ name: 'John' })
3535

3636
const App = () => (
37-
<State>
38-
<div>{get(s => s.name)}</div>
39-
</State>
37+
<div>{get(s => s.name)}</div>
4038
)
4139
```
4240

@@ -48,17 +46,15 @@ Instead of defining actions or something else to change your state, with reworm
4846
import React from 'react'
4947
import { create } from 'reworm'
5048

51-
const { State, set, get } = create({ name: 'John' })
49+
const { set, get } = create({ name: 'John' })
5250

5351
class App extends React.Component {
5452
componentDidMount() {
5553
set(prev => ({ name: 'Peter' + prev.name }))
5654
}
5755
render() {
5856
return (
59-
<State>
60-
<div>{get(s => s.name)}</div>
61-
</State>
57+
<div>{get(s => s.name)}</div>
6258
)
6359
}
6460
}
@@ -72,16 +68,14 @@ Selectors are good because they prevent you from duplicating code. With it you c
7268
import React from 'react'
7369
import { create } from 'reworm'
7470

75-
const { State, select } = create({ list: ['Peter', 'John'] })
71+
const { select } = create({ list: ['Peter', 'John'] })
7672

7773
const johnSelector = select(state =>
78-
state.list.find(user => user.includes('Peter'))
74+
state.list.find(user => user.includes('John'))
7975
)
8076

8177
const App = () => (
82-
<State>
83-
<div>{johnSelector(user => user)}</div>
84-
</State>
78+
<div>{johnSelector(user => user)}</div>
8579
)
8680
```
8781

@@ -90,28 +84,25 @@ const App = () => (
9084
#### `create<T>(initial?: T): State`
9185
Create a new state
9286

93-
#### `State<T>: ReactComponent<{ initial?: T }>`
94-
Use this component as wrapper when you want to access your state
95-
9687
#### `get((state: T) => React.ReactNode)`
9788
Use this method to access your state
9889

9990
#### `set((state: T | (prevState: T) => T) => T)`
10091
Use this method to set your state
10192

102-
#### `select(selector: (state: T) => T) => (fn: GetFn<T>) => React.ReactNode`
93+
#### `select<S = any>(selector: (state: T) => S) => (fn: GetFn<T>) => React.ReactNode`
10394
Create selectors that can be used with your state and avoid repeating code.
10495

10596
```js
10697
import React from 'react'
10798
import { create } from 'reworm'
10899

109-
const { State, select } = create({ name: 'John' })
100+
const { select } = create({ name: 'John' })
110101
const userSelector = select(s => s.name)
111102

112103
const App = () => (
113104
<State>
114-
{userSelector}
105+
{userSelector(name => name)}
115106
</State>
116107
)
117108
```
@@ -129,8 +120,7 @@ type GetFn<T> = (state: T) => React.ReactNode
129120
interface State<T> {
130121
get: (fn: GetFn<T>) => React.ReactNode
131122
set: (param: T | PrevState<T>) => void
132-
select: <S = T>(selector: (state: T) => S) => (fn: GetFn<S>) => React.ReactNode
133-
State: React.ComponentType<ProviderProps<T>>
123+
select: <S = any>(selector: (state: T) => S) => (fn: GetFn<S>) => React.ReactNode
134124
}
135125

136126
function create<T>(initial: T) => State<T>

0 commit comments

Comments
 (0)