margelo / react-native-worklets-core

🧵 A library to run JS functions ("Worklets") on separate Threads
https://margelo.io
MIT License
578 stars 37 forks source link

With third-party libraries, context is lost #200

Closed HEYURAN closed 6 months ago

HEYURAN commented 6 months ago

// npx react-native@0.71.4 init AwesomeProject --version 0.71.4

"dependencies": { "@types/lodash": "^4.17.4", "lodash": "^4.17.21", "react": "18.2.0", "react-native": "0.74.1", "react-native-device-info": "^11.1.0", "react-native-worklets-core": "^1.3.3" },

` import {Worklets} from 'react-native-worklets-core'; import DeviceInfo from 'react-native-device-info'; import _ from 'lodash';

export function test() { console.log('test function getDeviceId---> ', DeviceInfo.getDeviceId()); console.log('test function lodash----> ', ); } Worklets.defaultContext.runAsync(() => { 'worklet'; try { ('worklet'); //console.log('Worklets-getDeviceId-------->',DeviceInfo?.getDeviceId(),); console.log('Worklets-lodash-------->', ); } catch (e) { console.log('Worklets-catch----------', e.message); } }); ` 5 6

HEYURAN commented 6 months ago

5-1