You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
./src/react/packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Attempted import error: 'afterActiveInstanceBlur' is not exported from './ReactFiberHostConfig'.
我们进入到ReactFiberHostConfig文件,修改下导出:
// @file src/react/packages/react-reconciler/src/ReactFiberHostConfig.js
// 当前文件下其他内容全部注释掉即可,没用
export * from './forks/ReactFiberHostConfig.dom'
此时编译会继续报错:
./src/index.js
Attempted import error: 'react' does not contain a default export (imported as 'React').
import * as React from 'react';
import * as ReactDOM from 'react-dom';
接下来会继续报编译的错:
./src/react/packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Attempted import error: 'unstable_flushAllWithoutAsserting' is not exported from 'scheduler' (imported as 'Scheduler').
Error: Internal React error: invariant() is meant to be replaced at compile time. There is no runtime version.
上面报错函数invariant报错,现在我们去处理invariant函数:
// @file src/react/packages/shared/invariant.js
export default function invariant(condition, format, a, b, c, d, e, f) {
return false; // 加上这个,啥也不管直接返回false
throw new Error(
'Internal React error: invariant() is meant to be replaced at compile ' +
'time. There is no runtime version.',
);
}
接下来,重新执行yarn start,看浏览器:
yeah,成功了!!!
The text was updated successfully, but these errors were encountered:
网上找了好多debug react的文章,在17上都不好使;在其他前辈们的基础上,进行了自己的尝试,记录下来,算是个开头,使用的是yarn不是npm哈。
create-react-app study-react
cd study-react && yarn eject
yarn start
,确保现在的项目是可以run起来的,结果TMD报错:yarn add -D @babel/plugin-syntax-jsx
yarn start
,这次跑起来了,打开浏览器输入:http://localhost:3000/
,可以看到如下界面:git submodule add [email protected]:facebook/react.git
,然后切换分支:cd react && git checkout tags/v17.0.0 -b v17.0.0
yarn start
,编译报错:yarn start
;yarn start
后,发现还是报错yarn start
,看浏览器:yeah,成功了!!!
The text was updated successfully, but these errors were encountered: