useContext from function dynamically imported

I'm building a keyboard shortcut management system and wanted to be able to dynamically import the action associated with a keybinding. Some of these keybindings may use a context so I've intentionally put the keyboard shortcut manager provider inside of all other providers.

action: () => import("../actions/switchColorScheme")


and in my index file:
<I18nProvider>
  <ColorSchemeProvider>
    <KeyboardShortcutManagerProvider>
      <Router root={App}>{routes}</Router>
    </KeyboardShortcutManagerProvider>
  </ColorSchemeProvider>
</I18nProvider>


I'm getting an error when trying to
useContext()
in the action file's default function. Is that expected or is there a correct way of doing this? I thought that intentionally nesting the contexts where they'd normally work would be fine.
Was this page helpful?