Reanimated2创建worklet失败,可能是你忘记添加Reanimated的babel插件了?

我尝试了所有以前的解决方案,但没有人解决我的问题,我试图解决它 2 天

这是我的 babel 文件

我的代码

import React, { useRef, useState } from 'react'
import { View, useWindowDimensions, Button } from 'react-native'
import Animated, { runOnUI } from 'react-native-reanimated';

export default function Login() {
    const { width, height } = useWindowDimensions();
    // const value = useSharedValue(0);
    function someWorklet(greeting: any) {
        'worklet';
        console.log("Hey I'm running on the UI thread");
    }

    return (
        <View style={{ flex: 1, justifyContent: 'flex-end', alignItems: 'center' }}>
            <Button title="click me" onPress={() => runOnUI(someWorklet)('Howdy')} />
        </View>
    );

}

回答

如果您正在使用 expo,请尝试使用expo r -c.


以上是Reanimated2创建worklet失败,可能是你忘记添加Reanimated的babel插件了?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>