#Is there a way to conditionally import fetcher?
1 messages · Page 1 of 1 (latest)
In this circumstance it's a menu. When on the remix app I would like to make these items clickable so a user can edit them, and have it interact with fetcher.
But outside of here I want to render the same component to a wordpress site for example, and don't want to send out a component that has useFetcher in it at all
Some ideas
-
Dynamically import the useFetcher module: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#importing_defaults
-
Create 2 versions of the same component & then dynamically import the component based on your condition
const ComponentA = lazy(() => import('path/to/componentA'));
if(some_condition_is_true) {
<ComponentA />
}
I'm going to try that dynamic import, I've actually never needed to use it before and I've read about it