qreact icon indicating copy to clipboard operation
qreact copied to clipboard

React.createElement第一个参数只能是函数或字符串

Open chenhongen opened this issue 7 years ago • 2 comments

异常出现在create-react-app + react-app-rewired中使用时,求指导。

  • config-overrides.js
module.exports = function override(config, env) {
	// do stuff with the webpack config...
	config.resolve = config.resolve || {};
        config.resolve.alias = config.resolve.alias || {};
	config.resolve.alias['react'] = 'qreact/dist/ReactIE';
	config.resolve.alias['react-dom'] = 'qreact/dist/ReactIE';
	config.resolve.alias['prop-types'] = 'qreact/lib/ReactPropTypes';
	config.resolve.alias['create-react-class'] = 'qreact/lib/createClass';

	config.resolve.alias['react-tap-event-plugin'] = 'qreact/lib/injectTapEventPlugin.js';

    return config;
};
  • index.js
require('es5-shim/es5-sham');

const React = require('react');
const ReactDOM = require('react-dom');
const App = require('./App');
//const registerServiceWorker = require('./registerServiceWorker');


ReactDOM.render(<App />, document.getElementById('root'));
//registerServiceWorker();```

chenhongen avatar May 17 '18 07:05 chenhongen

这个问题好像是因为.babelrc文件没启用造成的。我修改如下后可以了,但是目前在IE8下出现“缺少标识符”问题。。

const { getBabelLoader, injectBabelPlugin } = require('react-app-rewired');

module.exports = function override(config, env) {

	// do stuff with the webpack config...
	config.resolve = config.resolve || {};
        config.resolve.alias = config.resolve.alias || {};
	config.resolve.alias['react'] = 'qreact/dist/ReactIE';
	config.resolve.alias['react-dom'] = 'qreact/dist/ReactIE';
	config.resolve.alias['prop-types'] = 'qreact/lib/ReactPropTypes';
	config.resolve.alias['create-react-class'] = 'qreact/lib/createClass';

	config.resolve.alias['react-tap-event-plugin'] = 'qreact/lib/injectTapEventPlugin.js';

	getBabelLoader.call(injectBabelPlugin, config.module.rules).options.babelrc = true

    return config;
};

chenhongen avatar May 17 '18 08:05 chenhongen

不知道Qreact支不支持typescript

watsonhaw avatar Feb 27 '19 00:02 watsonhaw