Make sure WorkList has access to AppConfig
This commit is contained in:
1 parent
6e65e7eaf5
commit
c3ecbadbc2
7 files changed
+39
-38
No files matched your search
@@ -1,8 +0,0 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const APP_CONFIG_DEFAULT_VALUE = {
|
||||
appConfig: {},
|
||||
setCurrentAppConfig: () => {},
|
||||
};
|
||||
|
||||
export const appConfigContext = createContext(APP_CONFIG_DEFAULT_VALUE);
|
||||
@@ -0,0 +1,20 @@
|
||||
import React, { useState, createContext, useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const appConfigContext = createContext(null);
|
||||
const { Provider } = appConfigContext;
|
||||
|
||||
export const useAppConfig = () => useContext(appConfigContext);
|
||||
|
||||
export function AppConfigProvider({ children, value: initAppConfig }) {
|
||||
const [appConfig, setAppConfig] = useState(initAppConfig);
|
||||
|
||||
return <Provider value={[appConfig]}>{children}</Provider>;
|
||||
}
|
||||
|
||||
AppConfigProvider.propTypes = {
|
||||
children: PropTypes.any,
|
||||
value: PropTypes.any,
|
||||
};
|
||||
|
||||
export default AppConfigProvider;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { AppConfigProvider, useAppConfig } from './appConfig.js';
|
||||
|
||||
export { AppConfigProvider, useAppConfig };
|
||||
Reference in new issue
Block a user