You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✔ What is the name of the npm package? … react-native-test
✔ What is the description for the package? … xxx
✔ What is the name of package author? … Alessio Bianchi
✔ What is the email address for the package author? …
✔ What is the URL for the package author? …
✔ What is the URL for the repository? …
✔ What type of library do you want to develop? › Native view
✔ Which languages do you want to use? › Kotlin & Swift
✔ Project created successfully at test!
It seems like whenever you trigger a refresh, this line gets called:
requireNativeComponent<TestProps>(ComponentName)
Forcing RN to load the same view twice.
My solution would be to extract this particular call into a separate file like this:
// TestView.tsximport{requireNativeComponent,UIManager,Platform,ViewStyle,}from'react-native';constLINKING_ERROR=`The package 'react-native-test' doesn't seem to be linked. Make sure: \n\n`+Platform.select({ios: "- You have run 'pod install'\n",default: ''})+'- You rebuilt the app after installing the package\n'+'- You are not using Expo Go\n';typeTestProps={color: string;style: ViewStyle;};constComponentName='TestView';exportconstTestView=UIManager.getViewManagerConfig(ComponentName)!=null
? requireNativeComponent<TestProps>(ComponentName)
: ()=>{thrownewError(LINKING_ERROR);};
// index.tsxexport*from"./TestView"
And in theory, you won't have to touch TestView.tsx again and you can make as many changes you want to the index.tsx this way.
But I wonder if we should shape the template like this? @satya164
Description
Steps to reproduce:
npx create-react-native-library@latest test
src/index.tsx
where the custom view bridge is defined, for example add a simple newline at the end of the fileActual:
The error:
is displayed in the console and in the Android app.
The error points to the
requireNativeComponent
line of the following code insrc/index.tsx
:Expected:
no errors should be shown.
Packages
Selected options
✔ What is the name of the npm package? … react-native-test
✔ What is the description for the package? … xxx
✔ What is the name of package author? … Alessio Bianchi
✔ What is the email address for the package author? …
✔ What is the URL for the package author? …
✔ What is the URL for the repository? …
✔ What type of library do you want to develop? › Native view
✔ Which languages do you want to use? › Kotlin & Swift
✔ Project created successfully at test!
Link to repro
No response
Environment
The text was updated successfully, but these errors were encountered: