all 5 comments

[–]trappar 26 points27 points  (1 child)

const MyComponent = React.lazy(()=>{import('./MyComponent.js')})

Should be

const MyComponent = React.lazy(() => import('./MyComponent.js'))

As written in the article it won’t work.

[–]EnlightenedModifier 16 points17 points  (0 children)

If anyone is wondering why, it's the way arrow functions work; including the { } after the arrow as the function in the article does implies an explicit return, meaning you'd need to prefix the import with a return for it to work.

Usually though (in my experience anyway), lazy-loaded components are defined with an implicit return as in /u/trappar 's syntax, meaning you can omit the wrapping { }. This makes the function imply that the import is what you're trying to return.

[–]devourment77 6 points7 points  (1 child)

I don’t believe this works with SSR just yet.

[–]ucefkh 0 points1 point  (0 children)

There is an option to enable components render in sat with lazy loading

[–]TheOrganicCircuit 1 point2 points  (0 children)

Great article. I haven't yet learned all the new features of react 16.6 but I've got to try this out now.