1

i am working on a React project , previously i implemented code splitting on this project with React.Lazy feature on navigation routes. Currently it is hard to debug on this chunk files. I need to disable this lazy load on dev env so we can debug on source-map again. Is there anyway that React.lazy load like normal import statement ?

1 Answer 1

-1

I suppose you should refer to Environment Variables from React docs, and use something like

if (process.env.NODE_ENV === 'production') {
// code or components with lazy loads
} else {
// no lazy loads for debugging 
}
Sign up to request clarification or add additional context in comments.

1 Comment

this was my first approach ,it actually works but we have good amount of navigation and pages , i am looking for more generic solution , i also tried to write a function to handle all of this conditional stuff but it didn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.