Skip to content

Commit 3f4697b

Browse files
committed
update packages; remove areEqual workaround for React.memo
1 parent 633c9cc commit 3f4697b

File tree

21 files changed

+162
-384
lines changed

21 files changed

+162
-384
lines changed

README.md

Lines changed: 101 additions & 101 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@
5151
"mobx-react-lite": "^2.0.0-alpha.4",
5252
"react": "experimental",
5353
"react-dom": "experimental",
54-
"react-hooks-global-state": "^1.0.0-alpha.2",
55-
"react-redux": "^7.1.3",
54+
"react-hooks-global-state": "^1.0.0",
55+
"react-redux": "^7.2.0",
5656
"react-sweet-state": "^2.0.0",
5757
"react-tracked": "^1.0.6",
5858
"reactive-react-redux": "^4.5.0",
5959
"redux": "^4.0.5",
6060
"storeon": "^0.9.8",
6161
"use-context-selector": "^1.0.1",
6262
"use-subscription": "^1.3.0",
63-
"zustand": "^2.2.2"
63+
"zustand": "^2.2.3"
6464
},
6565
"devDependencies": {
6666
"@babel/cli": "^7.8.4",
@@ -74,7 +74,7 @@
7474
"eslint-plugin-import": "^2.20.1",
7575
"eslint-plugin-jsx-a11y": "^6.2.3",
7676
"eslint-plugin-react": "^7.18.3",
77-
"eslint-plugin-react-hooks": "^2.3.0",
77+
"eslint-plugin-react-hooks": "^2.4.0",
7878
"html-webpack-plugin": "^3.2.0",
7979
"http-server": "^0.12.1",
8080
"jest": "^25.1.0",

src/common.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,3 @@ export const useCheckTearing = () => {
6767
}
6868
});
6969
};
70-
71-
// naive shallowEqual for React.memo
72-
// a hack until the issue is resolved
73-
// https://github.com/facebook/react/issues/17314
74-
// https://github.com/facebook/react/issues/17318
75-
export const shallowEqual = (prevProps, nextProps) => {
76-
const prevKeys = Object.keys(prevProps);
77-
const nextKeys = Object.keys(nextProps);
78-
return prevKeys.every((key) => prevProps[key] === nextProps[key])
79-
&& nextKeys.every((key) => prevProps[key] === nextProps[key]);
80-
};

src/constate/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const useValue = () => React.useReducer(reducer, initialState);
@@ -19,7 +18,7 @@ const Counter = React.memo(() => {
1918
const { count } = state;
2019
syncBlock();
2120
return <div className="count">{count}</div>;
22-
}, shallowEqual);
21+
});
2322

2423
const Main = () => {
2524
const [state, dispatch] = useValueContext();

src/mobx-react-lite/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
initialState,
88
ids,
99
useCheckTearing,
10-
shallowEqual,
1110
} from '../common';
1211

1312
const Ctx = createContext();
@@ -19,7 +18,7 @@ const Counter = React.memo(() => {
1918
syncBlock();
2019
return <div className="count">{count}</div>;
2120
});
22-
}, shallowEqual);
21+
});
2322

2423
const Main = () => {
2524
const store = useContext(Ctx);

src/mobx-use-sub/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
initialState,
1010
ids,
1111
useCheckTearing,
12-
shallowEqual,
1312
} from '../common';
1413

1514
function useCount(store) {
@@ -26,7 +25,7 @@ const Counter = React.memo(() => {
2625
const count = useCount(store);
2726
syncBlock();
2827
return <div className="count">{count}</div>;
29-
}, shallowEqual);
28+
});
3029

3130
const Main = () => {
3231
const store = useContext(Ctx);

src/react-apollo/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
initialState,
1312
} from '../common';
1413

@@ -81,7 +80,7 @@ const Counter = React.memo(() => {
8180
const { loading, error, data } = useQuery(COUNT_QUERY, { fetchPolicy: 'cache-only' });
8281
syncBlock();
8382
return <div className="count">{(!loading && !error && data) ? data.count : 0}</div>;
84-
}, shallowEqual);
83+
});
8584

8685
const Main = () => {
8786
const [increment] = useMutation(INCREMENT_MUTATION);

src/react-hooks-global-state-1/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const { dispatch, useGlobalState } = createStore(reducer, initialState);
@@ -17,7 +16,7 @@ const Counter = React.memo(() => {
1716
const [count] = useGlobalState('count');
1817
syncBlock();
1918
return <div className="count">{count}</div>;
20-
}, shallowEqual);
19+
});
2120

2221
const App = () => {
2322
const [count] = useGlobalState('count');

src/react-hooks-global-state-2/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const { dispatch, useGlobalStateProvider, useGlobalState } = createStore(reducer, initialState);
@@ -17,7 +16,7 @@ const Counter = React.memo(() => {
1716
const [count] = useGlobalState('count');
1817
syncBlock();
1918
return <div className="count">{count}</div>;
20-
}, shallowEqual);
19+
});
2120

2221
const Main = () => {
2322
const [count] = useGlobalState('count');

src/react-redux/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const store = createStore(reducer);
@@ -17,7 +16,7 @@ const Counter = React.memo(() => {
1716
const count = useSelector((state) => state.count);
1817
syncBlock();
1918
return <div className="count">{count}</div>;
20-
}, shallowEqual);
19+
});
2120

2221
const Main = () => {
2322
const dispatch = useDispatch();

src/react-state/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
useRegisterIncrementDispatcher,
55
ids,
66
useCheckTearing,
7-
shallowEqual,
87
reducer,
98
initialState,
109
} from '../common';
@@ -15,7 +14,7 @@ const Counter = React.memo(() => {
1514
const store = useContext(Ctx);
1615
syncBlock();
1716
return <div className="count">{store}</div>;
18-
}, shallowEqual);
17+
});
1918

2019
const Main = ({ dispatch }) => {
2120
const store = useContext(Ctx);

src/react-sweet-state/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const Store = createStore({
@@ -27,7 +26,7 @@ const Counter = React.memo(() => {
2726
const { count } = state;
2827
syncBlock();
2928
return <div className="count">{count}</div>;
30-
}, shallowEqual);
29+
});
3130

3231
const Main = () => {
3332
const [state, actions] = useCounter();

src/react-tracked/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const useValue = () => React.useReducer(reducer, initialState);
@@ -19,7 +18,7 @@ const Counter = React.memo(() => {
1918
const count = useSelector((state) => state.count);
2019
syncBlock();
2120
return <div className="count">{count}</div>;
22-
}, shallowEqual);
21+
});
2322

2423
const Main = () => {
2524
const dispatch = useDispatch();

src/reactive-react-redux/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const store = createStore(reducer);
@@ -17,7 +16,7 @@ const Counter = React.memo(() => {
1716
const count = useSelector((state) => state.count);
1817
syncBlock();
1918
return <div className="count">{count}</div>;
20-
}, shallowEqual);
19+
});
2120

2221
const Main = () => {
2322
const dispatch = useDispatch();

src/salvoravida-react-redux/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const store = createStore(reducer);
@@ -17,7 +16,7 @@ const Counter = React.memo(() => {
1716
const count = useSelector((state) => state.count);
1817
syncBlock();
1918
return <div className="count">{count}</div>;
20-
}, shallowEqual);
19+
});
2120

2221
const Main = () => {
2322
const dispatch = useDispatch();

src/simplux/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
useRegisterIncrementDispatcher,
88
ids,
99
useCheckTearing,
10-
shallowEqual,
1110
initialState,
1211
} from '../common';
1312

@@ -33,7 +32,7 @@ const Counter = React.memo(() => {
3332
const count = useSimplux(counter.value);
3433
syncBlock();
3534
return <div className="count">{count}</div>;
36-
}, shallowEqual);
35+
});
3736

3837
const Main = () => {
3938
const count = useSimplux(counter.value);

src/storeon/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
reducer,
1111
ids,
1212
useCheckTearing,
13-
shallowEqual,
1413
} from '../common';
1514

1615
const counter = (store) => {
@@ -24,7 +23,7 @@ const Counter = React.memo(() => {
2423
const { count } = useStoreon('count');
2524
syncBlock();
2625
return <div className="count">{count}</div>;
27-
}, shallowEqual);
26+
});
2827

2928
const Main = () => {
3029
const { count, dispatch } = useStoreon('count');

src/use-context-selector/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const context = createContext(null);
@@ -26,7 +25,7 @@ const Counter = React.memo(() => {
2625
const count = useContextSelector(context, (v) => v[0].count);
2726
syncBlock();
2827
return <div className="count">{count}</div>;
29-
}, shallowEqual);
28+
});
3029

3130
const Main = () => {
3231
const dispatch = useContextSelector(context, (v) => v[1]);

src/use-subscription/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const store = createStore(reducer);
@@ -20,7 +19,7 @@ const Counter = React.memo(() => {
2019
}), []));
2120
syncBlock();
2221
return <div className="count">{count}</div>;
23-
}, shallowEqual);
22+
});
2423

2524
const Main = () => {
2625
const count = useSubscription(React.useMemo(() => ({

src/zustand/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
reducer,
99
ids,
1010
useCheckTearing,
11-
shallowEqual,
1211
} from '../common';
1312

1413
const [useStore] = create((set) => ({
@@ -20,7 +19,7 @@ const Counter = React.memo(() => {
2019
const count = useStore((state) => state.count);
2120
syncBlock();
2221
return <div className="count">{count}</div>;
23-
}, shallowEqual);
22+
});
2423

2524
const Main = () => {
2625
const count = useStore((state) => state.count);

0 commit comments

Comments
 (0)