Thứ Tư, 1 tháng 2, 2023

Linking Local Packages in React Native the Right Way

https://medium.com/@alielmajdaoui/linking-local-packages-in-react-native-the-right-way-2ac6587dcfa2

-- 

Step 1: Simply add the property watchFolders to the exports object. 

Your metro.config.js file should look something like:


// Absolute path to your package

const packagePath =

    '/Users/mac/my-own-packages/my-awesome-package';


module.exports = {

    resolver: {

        nodeModulesPaths: [packagePath],

        // rest of metro resolver options...

    },

    watchFolders: [packagePath],

    // rest of metro options...

};


Step 2:

npm install /Users/mac/my-own-packages/my-awesome-package