October 2019
Intermediate to advanced
426 pages
11h 49m
English
A better way to use contexts is with the useContext Hook! That way, we can use context values like any other value, in a similar way to the useState Hook:
import React, { useContext } from 'react'import { ThemeContext } from './App'
const Header = ({ text }) => { const theme = useContext(ThemeContext)
return <h1 style={{ color: theme.primaryColor }}>{text}</h1>Read now
Unlock full access