7.0.9 • Published 1 year ago

@allbin/with-config v7.0.9

Weekly downloads
11
License
ISC
Repository
github
Last release
1 year ago

@allbin/with-config

Example

src/config.ts:

interface ConfigType {
  [...]
}

export const default_config: ConfigType = {
  [...]
}

const ConfigContext = React.createContext<ConfigType>(default_config);
export default ConfigContext;

src/index.tsx:

import WithConfig from '@allbin/with-config';
import ConfigContext, { default_config } from './config';

[...]

ReactDOM.render(
  <WithConfig Context={ConfigContext} default_config={default_config}>
    <...>
  </WithConfig>
)

src/views/View.tsx:

import ConfigContext from '../config';


const View = React.FC = () => {
  const config = useContext(ConfigContext);

  [...]
}
7.0.8

1 year ago

7.0.9

1 year ago

7.0.7

3 years ago

7.0.6

4 years ago