question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?

See original GitHub issue

Bug

Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated’s babel plugin? shows me when i tried to run this lib in expo project.

Environment info

Library Version
@gorhom/bottom-sheet Release 3.6.6
react-native 0.64
react-native-reanimated 2.2.0
react-native-gesture-handler 1.10.3

Steps To Reproduce

  1. Copy and paste code in example and got error Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated’s babel plugin?

Describe what you expected to happen:

1.Expected to run example in github image

Reproducible sample code

My code so far:

import React, { useCallback, useRef, useMemo } from "react";
import { StyleSheet, View, Text, Button } from "react-native";
import BottomSheet, { BottomSheetFlatList } from "@gorhom/bottom-sheet";

const App = () => {
  // hooks
  const sheetRef = useRef(null);

  // variables
  const data = useMemo(
    () =>
      Array(50)
        .fill(0)
        .map((_, index) => `index-${index}`),
    []
  );
  const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);

  // callbacks
  const handleSheetChange = useCallback((index) => {
    console.log("handleSheetChange", index);
  }, []);
  const handleSnapPress = useCallback((index) => {
    sheetRef.current?.snapTo(index);
  }, []);
  const handleClosePress = useCallback(() => {
    sheetRef.current?.close();
  }, []);

  // render
  const renderItem = useCallback(
    ({ item }) => (
      <View style={styles.itemContainer}>
        <Text>{item}</Text>
      </View>
    ),
    []
  );
  return (
    <View style={styles.container}>
      <Button title="Snap To 90%" onPress={() => handleSnapPress(2)} />
      <Button title="Snap To 50%" onPress={() => handleSnapPress(1)} />
      <Button title="Snap To 25%" onPress={() => handleSnapPress(0)} />
      <Button title="Close" onPress={() => handleClosePress()} />
      <BottomSheet
        ref={sheetRef}
        snapPoints={snapPoints}
        onChange={handleSheetChange}
      >
        <BottomSheetFlatList
          data={data}
          keyExtractor={(i) => i}
          renderItem={renderItem}
          contentContainerStyle={styles.contentContainer}
        />
      </BottomSheet>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 200,
  },
  contentContainer: {
    backgroundColor: "white",
  },
  itemContainer: {
    padding: 6,
    margin: 6,
    backgroundColor: "#eee",
  },
});

export default App;

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
likeSocommented, Jul 11, 2021
  • Please make sure you installed reanimated latest version by expo install
  • babel plugin
  • try start your project by expo start --clear

May this helpful

1reaction
likeSocommented, Jul 11, 2021

Have you followed expo’s install guide? Configured babel config?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reanimated 2 failed to create a worklet, maybe you forgot to ...
Description Getting Issue in build compilation- Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?
Read more >
Reanimated 2 failed to create a worklet, maybe you forgot to ...
The error is: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin? react-native ...
Read more >
Error: Reanimated 2 failed to create a worklet
Error : Reanimated 2 failed to create a worklet — Maybe You Forgot to Add Reanimated's babel Plugin? The solution… Photo by Richard...
Read more >
Reanimated 2 failed to create a worklet, maybe you ... - Reddit
When I add this imports I get title error. import Animated, { useAnimatedStyle, useSharedValue, withDelay, withRepeat, withTiming, ...
Read more >
Installation | React Native Reanimated - Software Mansion
After adding the react-native-reanimated/plugin to your project you may encounter a false-positive "Reanimated 2 failed to create a worklet" error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found