Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ReactJS Training Day 4 | Abhisek Pattnaik | Impelsys

ReactJS Training Day 4 | Abhisek Pattnaik | Impelsys

More Hooks
- useCallback
- useMemo

Forms

Abhisek Pattnaik

December 29, 2022
Tweet

More Decks by Abhisek Pattnaik

Other Decks in Programming

Transcript

  1. WELCOME TO REACTJS TRAINING DAY 4 ...by Abhisek Pattnaik Senior

    Software Engineer CE Services, Heart Bangalore
  2. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. 1. More Hooks 2. Form 3. Resources 4. Exercise Agenda
  3. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I ❤ ReactJS • useCallback – Caches the function. • useMemo – Caches value returned from a function call. • useReducer(reducer, initialArg, init?) dispatch(action) ⟶ reducer ⟶ update state ⟶ render immer (library) for JS style immutable object and array manipulation. • Strict Mode – Components are mounted twice for bug check. • Every render is like a Frame/Snapshot in a movie. (...sshh...closures at play) More Hooks
  4. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I ❤ ReactJS • Native Form controls have internal state. • Controlled Components – state and handler (from value/checked) • Uncontrolled Components – internal state • defaultValue – initial value for uncontrolled • useRef for uncontrolled • react-hook-form library https://react-hook-form.com Form
  5. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I ❤ ReactJS Uncontrolled vs Controlled feature uncontrolled controlled One time value retrieval (e.g. on submit) ✅ ✅ Validating on submit ✅ ✅ Instant field validation ❌ ✅ Conditionally disabling submit button ❌ ✅ Enforcing input format ❌ ✅ Several inputs for one piece of data ❌ ✅ Dynamic inputs ❌ ✅
  6. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I ❤ ReactJS • useCallback: https://beta.reactjs.org/reference/react/useCallback • useMemo: https://beta.reactjs.org/reference/react/useMemo • useReducer: https://beta.reactjs.org/reference/react/useReducer • Controlled Component: https://reactjs.org/docs/uncontrolled- components.html • Uncontrolled Component: https://reactjs.org/docs/uncontrolled- components.html • Profiling for performance: https://beta.reactjs.org/blog/2018/09/10/introducing-the-react- profiler Resources
  7. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. Grab your Phone Scan the QR Code and Go to the Slido Link https://app.sli.do/event/rDXg2dQQ7tunghJFTgQoGn or Join at slido.com #6366431
  8. Copyright © 2022 : (Heart Bangalore) Impelsys Inc. All Rights

    Reserved. I ❤ ReactJS • Create a Products component with a list of products (pre-defined). • Each product will have a "Add to Cart" button. • Add "Create Product Form" with Product "name", "price", and "availability" • Create a Cart component with a list of products • Each item should have "name", "price per unit", "quantity", "total price". • At the bottom, it should show total "quantity" and "price" of all the items. • Think your own UI... Exercise