Closed
Description
Hi there
There are times where we want the defaultValue for React's Context API to be null
.
I've found this solution.
TLDR:
import * as React from 'react';
interface AppContextInterface {
name: string,
author: string,
url: string
}
const {Provider, Consumer} = React.createContext<AppContextInterface | null>(null);
Now we can pass null
in as a default value as our React.createContext
argument.