Higher-Order Components, Portals and Strict Mode
Learn Higher-Order Components, Portals and Strict Mode (Phase 15 · Advanced Rendering Concepts (Advanced), ReactJS) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Higher-Order Components (HOC) • A HOC is a function that takes a component and returns a new component with extra behaviour: withAuth(Dashboard) , withLoading(List) . Libraries such as Redux's old connect and React Router's old withRouter used them. • Conventions: do not mutate the original component, pass through unrelated props, set a displayName , hoist statics, and never create a HOC inside render (new component type each render resets state). • Today hooks and composition replace most HOCs, but you will meet them in older codebases and for cross-cutting wrappers (auth guards, error...