- create project
with typescript template
npx create-react-app my-app
npx create-react-app my-app --template typescript
- start
cd <project directory> npm run start
- build project
- Functional Components (Pure function)
const Democomponent=()=> { return <h1>Welcome Message!</h1>; }
- Class Components
class Democomponent extends React.Component { constructor(props) { super(props); this.state = {count: 1}; } render(){ return <h1>Welcome Message!</h1>; } }
- Diff and should choose
Functional
orClass
component Refer it for brief comparation.
Refer: https://www.pluralsight.com/guides/react-communicating-between-components
- From parent to child with
props
- From child to parent with callbacks it is as same as EventEmit in angular
- From parent tof child with
context
- Sideways with non-react options