antd-mobile-pro icon indicating copy to clipboard operation
antd-mobile-pro copied to clipboard

关于脚手架的全局配置

Open biuge opened this issue 3 years ago • 0 comments

在app.tsx 下我想导出一个全局的路由配置 结果报错 Error: register failed, invalid key GlobalConfigContext from plugin 我查了下是因为umi的这个运行时配置需要注册plugin 可我只想要一个路由数据传给子节点用 有不有好的办法

export const GlobalConfigContext = React.createContext('');

export function patchRoutes({ routes, routeComponents }) {
  GlobalConfigContext._currentValue = {
    allRoutes: routes
  }
}

const GlobalConfigProvider = ({ children, value }: any) => {
  return (
    <GlobalConfigContext.Provider value={value}>
      {children}
    </GlobalConfigContext.Provider>
  )
}

export function rootContainer(container: any) {
  return React.createElement(GlobalConfigProvider, { value: {} }, container);
}

biuge avatar Nov 02 '22 06:11 biuge