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
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
}
1 Comment
Necati Sarhanlı
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.