margelo / react-native-worklets-core

🧵 A library to run JS functions ("Worklets") on separate Threads
https://margelo.io
MIT License
523 stars 36 forks source link
async background hacktoberfest multithreading native react threads worklet worklets

🧵 react-native-worklets-core

A Worklet runner for React Native.

const worklet = () => {
  'worklet'
  return Math.random()
}

[!NOTE] In most cases, react-native-worklets-core shouldn't be used as a standalone dependency but rather as a peer-dependency for other modules such as react-native-vision-camera, react-native-wishlist, or react-native-skia.

Installation

  1. Install the library from npm:
    yarn add react-native-worklets-core
  2. Add the babel plugin to your babel.config.js:
    module.exports = {
      plugins: [
        ["react-native-worklets-core/plugin"],
        // ...
      ],
      // ...
    };
  3. Restart Metro with clean cache:
    yarn start --reset-cache

Usage

See USAGE.md

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Credits