React.lazy with dynamic import should be printed in the same way
See original GitHub issuePrettier 1.14.3 Playground link
--parser babylon
--print-width 50
Input:
import Home from './Home'
import SomeLongLongComponent from './SomeLongLongComponent'
const Home = React.lazy(() => import('./Home'))
const SomeLongLongComponent = React.lazy(() => import('./SomeLongLongComponent'))
Output:
import Home from "./Home";
import SomeLongLongComponent from "./SomeLongLongComponent";
const Home = React.lazy(() => import("./Home"));
const SomeLongLongComponent = React.lazy(() =>
import("./SomeLongLongComponent")
);
Expected behavior:
import Home from "./Home";
import SomeLongLongComponent from "./SomeLongLongComponent";
const Home = React.lazy(() => import("./Home"));
const SomeLongLongComponent = React.lazy(() => import("./SomeLongLongComponent"));
or
import Home from "./Home";
import SomeLongLongComponent from "./SomeLongLongComponent";
const Home = React.lazy(() =>
import("./Home")
);
const SomeLongLongComponent = React.lazy(() =>
import("./SomeLongLongComponent")
);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Dynamically Importing Components with React.lazy
In React, dynamically importing a component is easy—you invoke React.lazy with the standard dynamic import syntax and specify a fallback UI.
Read more >Code-Splitting - React
The React.lazy function lets you render a dynamic import as a regular component. Before: import OtherComponent from './OtherComponent';. After:.
Read more >Understanding Dynamic imports, Lazy and Suspense using ...
We have a function called, importDemo which takes a file as an argument. This file argument represents the selected demo based on the...
Read more >React Lazy Loading: The Best Complete Guide - CopyCat Blog
`React lazy()` makes it easy to render react components that are imported using the dynamic import() technique. The components are rendered as ......
Read more >Mixing dynamic imports with if conditions - Stack Overflow
The smiley will only import if it is being rendered. // parent.js import * as React from 'react' const SmileyFace = React.lazy(() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can’t see the need for this.
I don’t think we should special case
React.lazy
at all, but we could change the formatting of a lambda if the body is animport()
expression. I don’t see why though…Yeah, agreed - it is a bit of a stretch.
I haven’t done a lot of work with dynamic imports yet, so I don’t have a very strong opinion at this time.