I used create-react-library to create a library that contains both native Android and iOS code. This library is not published and I want to use it in another react native project. So I copied the library into the project and tried to reference using relative path. It looked fine. But when I ran the project, I got the warning: Possible Unhandled Promise Rejection: Error: The package XXX doesn't seem to be linked.
Certainly when the library's function was called, I got the error: The package XXX doesn't seem to be linked. This is the error I saw on Android. I haven't done any linking on iOS and I am sure I will get similar error there.
I also tried to run:
npm install path-to-the-library
but got all kinds of errors. The following are a few of the errors:
npm ERR! code 1
npm ERR! path the-absolute-path-to-the-library
npm ERR! command failed
npm ERR! command sh -c bob build
npm ERR! i Building target commons
...
Then I realized there's a script in the library I created using create-react-native-library:
"prepare": "bob build"
So I tried to run this command, but it spit out some errors due to custom views I created using native component (https://reactnative.dev/docs/native-components-android, https://reactnative.dev/docs/native-components-ios) The native views have some properties that I wanted to be available on the react native component. The error I got is: CustomView cannot be used as JSX component. Its intrinsic type Component<unknown, {} any> & Readonly is not a valid JSX element.
When I was testing on the example project, I saw the same error, but the app built fine and could run. I would like to fix this error, but I could not find any documentation on how to do this in typescript. (BTW, create-react-native-library created the library project with typescript).
Is the second method I tried the correct method? If so, how can I fix the error that typescript requires?