Skip to content

What I learned from "React - The Complete Guide 2024 (incl. Next.js, Redux) - Academind by Maximilian Schwarzmüller"

Notifications You must be signed in to change notification settings

selmasaltik/react-refs-and-portals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 

Repository files navigation

Refs & Portals

Advanced DOM Access & Value Management

  • Accessing DOM Elements with Refs
  • Managing Values with Refs
  • Exposing API Functions from Components
  • Detaching DOM Rendering from JSX Structure with Portals

(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog)

State vs Refs

State

  • Causes component re-evaluation (re-execution) when changed
  • Should be used for values that are directly reflected in the UI
  • Should not be used for “behind the scenes” values that have no direct UI impact

Refs

  • Do not cause component re-evaluation when changed
  • Can be used to gain direct DOM element access (→ great for reading values or accessing certain browser APIs)

About

What I learned from "React - The Complete Guide 2024 (incl. Next.js, Redux) - Academind by Maximilian Schwarzmüller"

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published