Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
68 views
in Technique[技术] by (71.8m points)

javascript - How do I conditionally import react-devtools?

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?

question from:https://stackoverflow.com/questions/65840829/how-do-i-conditionally-import-react-devtools

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...