Home > Mobile >  How can I use an external library into my project which had a bug?
How can I use an external library into my project which had a bug?

Time:08-05

I want to use external library, which has a small bug. I know how to fix this bug and will create a PR request for it, but until it gets approved, how can I use the library in my project, without violating copy rights? The github repo is public (I don't know if it matters)

One idea (which I am pretty sure is wrong) is to copy-paste the code which I need and fix the bug. Another would be to use that code as an "inspiration" and just change the code down to the functionality which I need.

I am writing react native project and I have already installed the library, so it is included in my package.json file.

CodePudding user response:

You can create a patch package for that library using https://www.npmjs.com/package/patch-package and can use it in your project.

CodePudding user response:

You can fork the lib then apply the fix to your fork. Once it's done remove the lib from the package.json with yarn remove theLibraryToRemove Then add in your package.json: "name-of-the-lib": "yourGitName/your-fork-with-fix"

example with lib react-native-vision-camera :

First: yarn remove react-native-vision-camera

Then add to package.json: "react-native-vision-camera": "myGit/react-native-vision-camera-fork"

  • Related