Browse Source

fix: repeat import react (#21050)

pull/21053/head
陈小聪 5 years ago
committed by 二货机器人
parent
commit
ca3490f81a
  1. 6
      site/theme/template/Content/Demo/index.jsx

6
site/theme/template/Content/Demo/index.jsx

@ -214,13 +214,15 @@ class Demo extends React.Component {
// eslint-disable-next-line no-undef
{ react: 'latest', 'react-dom': 'latest', antd: antdReproduceVersion },
);
const importReactReg = /import(\D*)from 'react'/;
const importReactContent = importReactReg.test(sourceCode) ? '' : "import React from 'react';";
const indexJsContent = `
import React from 'react';
${importReactContent}
import ReactDOM from 'react-dom';
import 'antd/dist/antd.css';
import './index.css';
${sourceCode.replace('mountNode', "document.getElementById('container')")}
`;
`;
const indexCssContent = (style || '').replace(new RegExp(`#${meta.id}\\s*`, 'g'), '');
const codesanboxPrefillConfig = {
files: {

Loading…
Cancel
Save