@unholster/react-use-config
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

react-use-config

Hook that provides runtime configuration via a hosted config.json file

Example

import { useConfig, ConfigProvider } from '@unholster/react-use-config'

const CONFIG_PATH = ...

// to set default config add new or derive from existing config. Is optional.
const configAdapter = (config: ConfigType): AdaptedConfigType => {
  return {
    ...config,
    // add any additional properties here
  }
}

<ConfigProvider configPath={CONFIG_PATH} configAdapter={configAdapter} >
  <App />
</ConfigProvider>


function App() {
  const config = useConfig<AdaptedConfigType>()
  ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @unholster/react-use-config

Weekly Downloads

7

Version

1.0.8

License

none

Unpacked Size

48.7 kB

Total Files

9

Last publish

Collaborators

  • jacky_yam
  • archidemus
  • alan_ne
  • crvargasu
  • joyanedel
  • mbmadariaga-unh
  • jeschuwirth
  • ignaciotobar
  • sebaaacuna