Tutorial by Examples

Let's say we want to console.log each time the component mounts: hocLogger.js export default function hocLogger(Component) { return class extends React.Component { componentDidMount() { console.log('Hey, we are mounted!'); } render() { return <Component {...this....
Let's say we have a component that should only be displayed if the user is logged in. So we create a HOC that checks for the authentication on each render(): AuthenticatedComponent.js import React from "react"; export function requireAuthentication(Component) { return class Auth...

Page 1 of 1