-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(legacy view template): extract view to a separate file #375
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also do it for native modules and then merge
7b11914
to
6facf3b
Compare
@@ -0,0 +1,25 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name this file as <%- project.name -%>View.tsx
to match the name of the component it exports
|
||
const ComponentName = '<%- project.name -%>View'; | ||
|
||
export default UIManager.getViewManagerConfig(ComponentName) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally good to avoid default exports
export default UIManager.getViewManagerConfig(ComponentName) != null | |
export const <%- project.name -%>View = UIManager.getViewManagerConfig(ComponentName) != null |
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. |
Burak said we don't need this anymore |
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 theindex.tsx
reduces the DX as anytime you make changes to the 'index.tsxfile, you will get
Invariant Violation: Tried to register two views with the same name` error. This PR addresses these issues.Test plan
create-react-native-library
and select these options:src/
<Your Project Name>ViewNativeComponent.ts
exists with proper codeindex.tsx
index.tsx
, theInvariant Violation: Tried to register two views with the same name
error doesn't appear.