react-native-community/react-native-template-typescript

App.tsx - Section needs type for "children"

ameetmadan opened this issue · 5 comments

Expected results

What did you expect to happen?

App.tsx has no TypeScript errors

const Section: React.FC<{
  title: string;
  children: React.ReactNode; /* This line needs to be added to correct the errors */
}> = ({children, title}) => { ... }

Observed results

What happened?

App.tsx has TypeScript errors

const Section: React.FC<{
  title: string;
}> = ({children, title}) => { ... }
leotm commented

You've likely bumped @types/react to v18 (similar recent type error)

Sticking to

"resolutions": {
"@types/react": "^17"
},

should fix it, which keeps our PropsWithChildren type, meant for RN 0.68 and below

leotm commented

But yes RN 0.69.0-rc.0 bumps React to v18, when we'll want to bump @types/react to v18 with your change above

if you fancy giving it a shot (like here) - looking into it too, working well generally

Be sure you have yarn installed so that npx react-native init doesn't use npm to install the dependencies since "resolutions" is a yarn-specific field.

leotm commented

btw this should be resolved since #277

thanks again for raising and the suggestion ^

Yes, this is resolved now.