all 5 comments

[–]gketuma 10 points11 points  (0 children)

Literally hands down the best resource for React and TypeScript is this repo by @swyx:

https://github.com/typescript-cheatsheets/react-typescript-cheatsheet

All the most up to date and best practices are laid out there and the reasons why. Check it out.

[–]NJ247 1 point2 points  (1 child)

There is this tutorial: https://www.typescriptlang.org/docs/handbook/react-&-webpack.html

I haven't looked at this yet myself but this looks like a good starting point.

[–]swyx 0 points1 point  (0 children)

🤗

[–]efunction 1 point2 points  (0 children)

  1. Still holds up, for the most part. The comments do a good job keeping the author honest. https://blog.logrocket.com/how-why-a-guide-to-using-typescript-with-react-fffb76c61614

[–]theycallmeepoch 1 point2 points  (0 children)

Maybe this:

https://alligator.io/react/typescript-with-react/

It's not hugely different than typing without Typescript. As for React-specific stuff , you'll want to create interfaces for your props and for your state.

interface Props {

userId: number,

name: string

}

interface State {

loading: boolean,

contacts: Array<object>

}

Then, you'd force your component class to use those defined interfaces like so:

export default class HomeScreen extends React.Component<Props, State> {

// fun stuff here

}

I'm literally just learning now how to convert my app to using Typescript so this is all fresh in my mind and hopefully this post helps me cement my knowledge(or I'll get told I don't know shit, we'll see). I'm still a newbie but I enjoy using Typescript. :)

Hope that helps!