As I'm new to react I was searching for a way to use context api in my react app but couldn't find a way to use context api in functional component, most of them use it in class component. sorry for my question...
//this is my Context
import React,{ createContext, Component } from 'react';
export const ProductContext = createContext();
class ProductContextProvider extends Component {
state = {
light: 'a',
dark: 'b'
}
render() {
return(
<ProductContext.Provider value={{...this.state}}>
{this.props.children}
</ProductContext.Provider>
);
}
}
export default ProductContextProvider;