So I've been reading about using react context to avoid drilling of props. A basic example is has a component which provides a value which itself is kept in the Component state:
<ThemeContext.Provider value={this.state.shared, updateMyState}>
and a Consumer that uses that value.
Can I share the value of an exported list instead or should the Component which provides the Provider always refer to its state or a static value?
Here is what I mean:
file ./list:
export const list = [];
export const updateList = (val) => list.push(val);
file ./provider:
import Provider from './provider'
import {list, updateList} from ./list
{Provider, Consumer} = React.createContext();
export ProviderComponent = () =>
<Provider value={list, updateList}>
<children>
</Provider>
}