react-native-builder-bob
react-native-builder-bob copied to clipboard
feat(legacy view template): extract view to a separate file
Summary
Closes #370
Inspecting the codebase I've spotted that all of the view templates have the View initialized on a different file except the legacy view template. Having the view initialized in the index.tsx reduces the DX as anytime you make changes to the 'index.tsxfile, you will getInvariant Violation: Tried to register two views with the same name` error. This PR addresses these issues.
Test plan
- Run
create-react-native-libraryand select these options:
β ./create-react-native-library test
β What is the name of the npm package? β¦ react-native-test
β What is the description for the package? β¦ test
β What is the name of package author? β¦ Burak GuΜner
β What is the email address for the package author? β¦ [email protected]
β What is the URL for the package author? β¦ https://github.com/atlj
β What is the URL for the repository? β¦ https://github.com/atlj/react-native-test
β What type of library do you want to develop? βΊ Native view
β Which languages do you want to use? βΊ Kotlin & Swift
- Go inside
src/ - Make sure
<Your Project Name>ViewNativeComponent.tsexists with proper code - Make sure the view is imported and exposed in
index.tsx - Make sure the app is able to display the view
- Make sure when you make changes to
index.tsx, theInvariant Violation: Tried to register two views with the same nameerror doesn't appear.
You can find the diff here
Let's move the index file to common directory and change each type (legacy, new, mixed) to have this format for the view and module.