react-native-builder-bob icon indicating copy to clipboard operation
react-native-builder-bob copied to clipboard

feat(legacy view template): extract view to a separate file

Open atlj opened this issue 2 years ago β€’ 2 comments

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

  1. Run create-react-native-library and 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 Gü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
  1. Go inside src/
  2. Make sure <Your Project Name>ViewNativeComponent.ts exists with proper code
  3. Make sure the view is imported and exposed in index.tsx
  4. Make sure the app is able to display the view
  5. Make sure when you make changes to index.tsx, the Invariant Violation: Tried to register two views with the same name error doesn't appear.

atlj avatar Mar 21 '23 15:03 atlj

You can find the diff here

atlj avatar Oct 27 '23 21:10 atlj

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.

satya164 avatar Feb 02 '24 12:02 satya164