Skip to content
Snippets Groups Projects

Application context provider

Merged Christos requested to merge application-context-provider into master
1 file
+ 21
0
Compare changes
  • Side-by-side
  • Inline
+ 21
0
/* eslint react/prop-types: 0 */
/* eslint react/destructuring-assignment: 0 */
import React, { useEffect, useState } from 'react';
export const ApplicationContext = React.createContext({
app: null,
});
export default ({ app, children }) => {
const [application, setApplication] = useState(app);
useEffect(() => {
setApplication({ ...app });
}, [app]);
return (
<ApplicationContext.Provider value={{ app: application }}>
{children}
</ApplicationContext.Provider>
);
};