Skip to content

Commit

Permalink
Update docs for write support
Browse files Browse the repository at this point in the history
  • Loading branch information
spautz committed Jul 28, 2020
1 parent ca37eee commit 07cee74
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ import { SyncReduxToRecoil } from 'redux-to-recoil';
</Provider>;
```

If you want to sync changes from Recoil back to Redux, wrap your reducer with `syncChangesFromRecoil`

```typescript jsx
import { syncChangesFromRecoil } from 'redux-to-recoil';

// This will enable write-from-recoil
const reducer = syncChangesFromRecoil(yourRootReducer);
const store = createStore(reducer /* ... */);
```

```
// Writing from recoil works like normal
const todosAtom = atomFromRedux('.todos'); // wraps state.todos
const [todos, setTodos] = useRecoilState(todosAtom);
setTodos(newTodoList);
```

## Do I need this?

You probably don't need this. Redux and Recoil work fine side-by-side. You can already use values from Redux and Recoil
Expand Down

0 comments on commit 07cee74

Please sign in to comment.