Currently, I am delving into the world of building apps using TypeScript in React Native. Coming from a background as a Swift developer, adjusting to JavaScript and TypeScript has been an interesting journey.
An observation that stood out to me is the challenge of utilizing a component written in a tsx file within another tsx file in the Render method.
//SomeComponent.tsx
export default class SomeComponent extends Component {
//all my logic
}
//OtherComponent.tsx
export default class ScoreTable extends Component {
//logic
render() {
<SomeComponent style={{flex: 1}}></SomeComponent>
}
}
This scenario led to the following error message:
Type '{ style: { flex: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<SomeComponent> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'.
A quick fix for this issue was switching my tsx SomeComponent to a .js component, but I have grown fond of the tsx syntax. Hence, my question arises: Why can't I integrate .tsx components in other tsx components? Is there an alternative approach?