Skip to content

Commit

Permalink
Complete core read functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
spautz committed Jul 27, 2020
1 parent 3cbd17a commit ee0b48b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ It can also facilitate a migration from Redux to Recoil.
Until [Recoil issue #314](https://github.com/facebookexperimental/Recoil/issues/314) is worked, each component that
uses a Redux-linked atom or selector will rerender when Redux updates.

## Console error

Due to [Recoil issue #12](https://github.com/facebookexperimental/Recoil/issues/12), you will see a console error in
React 16.13. This does not hurt anything, but it is annoying.

> `Warning: Cannot update a component (`Batcher`) while rendering a different component`
## Roadmap

- [ ] Core functionality: SyncReduxToRecoil
Expand Down
2 changes: 1 addition & 1 deletion demos/todo-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"react-scripts": "3.4.1",
"recoil": "^0.0.10",
"redux": "^4.0.5",
"redux-to-recoil": "../../",
"redux-to-recoil": "latest",
"reselect": "^4.0.0"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions demos/todo-list/src/components.recoil/VisibleTodoList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { toggleTodo } from '../actions';
import getVisibleTodos from '../selectors/getVisibleTodos';
import Todo from './Todo';

// const todosSelector = selectorFromReselect(getVisibleTodos);
const todosSelector = selectorFromReselect(getVisibleTodos);

const VisibleTodoList = (props) => {
const dispatch = useDispatch();

// console.log()
const todos = []; //useRecoilValue(todosSelector);
const todos = useRecoilValue(todosSelector);

return (
<ul>
Expand Down
21 changes: 20 additions & 1 deletion demos/todo-list/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8850,6 +8850,11 @@ realpath-native@^1.1.0:
dependencies:
util.promisify "^1.0.0"

recoil@^0.0.10:
version "0.0.10"
resolved "https://registry.yarnpkg.com/recoil/-/recoil-0.0.10.tgz#679ab22306f559f8a63c46fd5ff5241539f9248f"
integrity sha512-+9gRqehw3yKETmoZbhSnWu4GO10HDb5xYf1CjLF1oXGK2uT6GX5Lu9mfTXwjxV/jXxEKx8MIRUUbgPxvbJ8SEw==

recursive-readdir@2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.2.tgz#9946fb3274e1628de6e36b2f6714953b4845094f"
Expand All @@ -8865,8 +8870,17 @@ redent@^3.0.0:
indent-string "^4.0.0"
strip-indent "^3.0.0"

"redux-to-recoil@file:../redux-to-recoil":
"redux-to-recoil@github:spautz/redux-to-recoil#dev--core-functionality":
version "0.0.1"
resolved "https://codeload.github.com/spautz/redux-to-recoil/tar.gz/3cbd17af6a4ea4875ad74fa6f7cbea49265f5de8"

redux@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==
dependencies:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"

regenerate-unicode-properties@^8.2.0:
version "8.2.0"
Expand Down Expand Up @@ -9988,6 +10002,11 @@ svgo@^1.0.0, svgo@^1.2.2:
unquote "~1.1.1"
util.promisify "~1.0.0"

symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==

symbol-tree@^3.2.2:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
Expand Down
6 changes: 4 additions & 2 deletions src/SyncReduxToRecoil.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useSelector, useStore } from 'react-redux';
import { useRecoilState } from 'recoil';

import { reduxStateAtom } from './internals';
Expand All @@ -15,9 +15,11 @@ const SyncReduxToRecoil: React.FC<SyncReduxToRecoilProps> = (props) => {

const [lastReduxState, setReduxState] = useRecoilState(reduxStateAtom);

const store = useStore();
console.log('store = ', store);

const currentReduxState = useSelector(selectEntireState);
if (enabled && currentReduxState !== lastReduxState) {
console.log('new currentReduxState!', currentReduxState);
setReduxState(currentReduxState);
}

Expand Down

0 comments on commit ee0b48b

Please sign in to comment.