Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ref from useAnimatedReaction hook #1412

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/reanimated2/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,6 @@ export function useAnimatedRef() {
* the second one can modify any shared values but those which are mentioned in the first worklet. Beware of that, because this may result in endless loop and high cpu usage.
*/
export function useAnimatedReaction(prepare, react, dependencies) {
const inputsRef = useRef(null);
if (inputsRef.current === null) {
inputsRef.current = {
inputs: Object.values(prepare._closure),
};
}
const { inputs } = inputsRef.current;

if (dependencies === undefined) {
dependencies = [
Object.values(prepare._closure),
Expand All @@ -598,7 +590,7 @@ export function useAnimatedReaction(prepare, react, dependencies) {
const input = prepare();
react(input);
};
const mapperId = startMapper(fun, inputs, []);
const mapperId = startMapper(fun, Object.values(prepare._closure), []);
return () => {
stopMapper(mapperId);
};
Expand Down