Reserved. 1. ReactJS Component based Architecture 2. JSX Syntax 3. Function vs Class Component 4. States and Props 5. React Lifecycle 6. Resources 7. Exercise Agenda
Reserved. I ❤ JSX • Use camelCase property names (JS Convetion) • React.createElement XML like alternative • ``` <div className="App"> <h1>Hello Abhisek</h1> </div> ``` Intro to JSX [Javascript + XML]
Reserved. I !❤ Prop Drilling • Pass information to a component • <Page title="Dashboard"> Welcome to the Dashboard Page </Page> • children Prop • Babel JSX Transform https://bit.ly/3VuSEEh Props
Reserved. I ❤ ReactJS • With internal state • Lifecycle methods • componentDidMount (e.g. setup timers/fetch) • componentWillUnmount (e.g. cleanup timers/cancel fetch) • ...and others • Re-renders when either props or state change. • Helps you read legacy codebase. Class Component
Reserved. I ❤ ReactJS • State updates maybe batched. • Keep a local memory of component. • Used for re-rendering UI on change. • this.setState(<changing-state>) • State updates are async. • State update is merges with existing state. State (Class Component)
Reserved. I ❤ ReactJS • Build a Calculator App (Class components) • It should have a <DisplayResult /> comp. • It should have operand buttons (0-9) • It should have operator buttons (÷×-+) • It may support brackets. • Need not be interactive. • Think your own idea... Exercise