Skip to content

Commit

Permalink
fix(plugins): import react while using react16 (#11926)
Browse files Browse the repository at this point in the history
* fix(plugins): import react while using react16

* fix(plugins): import react while using react16
  • Loading branch information
hualigushi authored Dec 5, 2023
1 parent c88105b commit 4041a07
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/plugins/src/react-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default (api: IApi) => {
path: 'runtime.tsx',
content: enableQueryClient
? `
import React from 'react';
import { defaultContext, QueryClient, QueryClientProvider } from '${pkgPath}';
import { ReactQueryDevtools } from '${devtoolPkgPath}';
${reactQueryRuntimeCode}
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/src/styled-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export { styled, ThemeProvider, createGlobalStyle, css, keyframes, StyleSheetMan
api.writeTmpFile({
path: 'runtime.tsx',
content: `
import React from 'react';
${hasProvider ? `import { StyleSheetManager } from '${winPath(libPath)}';` : ``}
${styledComponentsRuntimeCode}
Expand Down
3 changes: 3 additions & 0 deletions packages/preset-umi/src/features/icons/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export default (api: IApi) => {
}
}
}
if (code.length) {
code.unshift("import React from 'react';");
}
api.writeTmpFile({
path: 'icons.tsx',
content: code.join('\n') || EMPTY_ICONS_FILE,
Expand Down

0 comments on commit 4041a07

Please sign in to comment.