Skip to content

Capturing Animated (default export from react-native-reanimated) in worklet causes error loop #1132

Closed
@kmagiera

Description

Description

When Animated object (and perhaps this may work for other complex objects too) is captured in a worklet, this results in some unexpected error/crash behavior

Steps To Reproduce

Render the app with one of the worklets capturing Animated object (see examples posted below).

Expected behavior

Properties under Animated access from within a worklet (e.g. Animated.Extrapolate.CLAMP) should return their actual values.

Actual behavior

The app goes into an error loop with the following stacktrace being thrown every second or so:

This error is located at:
    in FlatListStuff
    in RCTView (at View.js:34)
    in View (at AppContainer.js:106)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:132)
    in AppContainer (at renderApplication.js:39)
[Mon Aug 17 2020 10:30:17.100]  ERROR    Error: Exception in HostFunction: <unknown>

Snack or minimal code example

import Animated, { useAnimatedStyle } from 'react-native-reanimated';

function Something() {
  const something = useAnimatedStyle(() => {
    return { backgroundColor: Animated.Extrapolate.CLAMP };
  });
  return <Animated.View style={something}/>
}

Full example as prepared by @ryanbaldwin: https://gist.githubusercontent.com/ryanbaldwin/68a5fa2c35dbfadf3d3a3bab2e96590d/raw/c2c81c1c0b4fedd6b3e6e251ecf8c39bff210c42/App.js

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions