3

I want to conditionally import react-devtools based on an environment variable but eslint says that I can't import in the body of the module when I try to import react-dom

react-devtools requires that I import it before react-dom so what do I do?

import React from 'react';

import env from 'react-dotenv'
const _temp = env.DEV === "true" && import ("react-devtools");

import ReactDOM from 'react-dom';
import App from './App';
import { RecoilRoot } from 'recoil'

It gives errors on the last three lines. How do I resolve this?

feverdreme
  • 467
  • 4
  • 12

0 Answers0