prevent unused exec getCurrentValue after re-render (#22442)

This commit is contained in:
Behnam Mohammadi
2021-09-28 00:50:32 +03:30
committed by GitHub
parent 580e2f56d5
commit 8131de13e2

View File

@@ -264,11 +264,11 @@ export function useSubscription<Value>({
getCurrentValue: () => Value,
subscribe: (callback: Function) => () => void,
|}): Value {
const [state, setState] = useState({
const [state, setState] = useState(() => ({
getCurrentValue,
subscribe,
value: getCurrentValue(),
});
}));
if (
state.getCurrentValue !== getCurrentValue ||