mirror of
https://github.com/facebook/react.git
synced 2026-02-26 05:45:14 +00:00
prevent unused exec getCurrentValue after re-render (#22442)
This commit is contained in:
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user