Skip to content

Instantly share code, notes, and snippets.

View foxundermoon's full-sized avatar
🏠
Looking for a remote job

foxundermoon foxundermoon

🏠
Looking for a remote job
View GitHub Profile
@Restuta
Restuta / HOC.js
Last active February 27, 2022 06:56
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {