我尝试在react 16.2.0中使用griddle-react 1.0.3,但得到以下错误:"Typeerror: Cannot read property 'string‘of undefined“。如何解决此错误?我应该为react 16.2.0使用griddle 0.8.1吗?或者这是我正在使用的正确组合吗?
W20181002-15:38:55.733(5)? (STDERR) TypeError: Cannot read property 'string'
of undefined
W20181002-15:38:55.734(5)? (STDERR) at Object.<anonymous>
(D:\react_projects\backstage-check\node_modules\griddle-
react\dist\module\components\ColumnDefinition.js:42:33)
W20181002-15:38:55.735(5)? (STDERR) at Module._compile
(module.js:652:30)
W20181002-15:38:55.735(5)? (STDERR) at Object.Module._extensions..js
(module.js:663:10)
W20181002-15:38:55.736(5)? (STDERR) at Module.load (module.js:565:32)
W20181002-15:38:55.737(5)? (STDERR) at tryModuleLoad (module.js:505:12)
W20181002-15:38:55.738(5)? (STDERR) at Function.Module._load
(module.js:497:3)
W20181002-15:38:55.738(5)? (STDERR) at Module.require (module.js:596:17)
W20181002-15:38:55.739(5)? (STDERR) at require
(internal/module.js:11:18)
W20181002-15:38:55.740(5)? (STDERR) at Object.<anonymous>
(D:\react_projects\backstage-check\node_modules\griddle-
react\dist\module\components\index.js:15:25)
W20181002-15:38:55.741(5)? (STDERR) at Module._compile
(module.js:652:30)
W20181002-15:38:55.741(5)? (STDERR) at Object.Module._extensions..js
(module.js:663:10)
W20181002-15:38:55.742(5)? (STDERR) at Module.load (module.js:565:32)
W20181002-15:38:55.743(5)? (STDERR) at tryModuleLoad (module.js:505:12)
W20181002-15:38:55.743(5)? (STDERR) at Function.Module._load
(module.js:497:3)
W20181002-15:38:55.744(5)? (STDERR) at Module.require (module.js:596:17)
W20181002-15:38:55.744(5)? (STDERR) at require
(internal/module.js:11:18)
W20181002-15:38:55.745(5)? (STDERR) at Object.<anonymous>
(D:\react_projects\backstage-check\node_modules\griddle-
react\dist\module\index.js:31:19)
W20181002-15:38:55.746(5)? (STDERR) at Module._compile
(module.js:652:30)
W20181002-15:38:55.747(5)? (STDERR) at Object.Module._extensions..js
(module.js:663:10)
W20181002-15:38:55.748(5)? (STDERR) at Module.load (module.js:565:32)
W20181002-15:38:55.748(5)? (STDERR) at tryModuleLoad (module.js:505:12)
W20181002-15:38:55.749(5)? (STDERR) at Function.Module._load
(module.js:497:3)发布于 2019-03-13 09:15:16
请尝试更新到最新版本。我打赌你安装了npm i --save react-griddle@beta (不要使用测试版)。并使用npm i --save react-griddle。
原因是propType,它是react核心的一部分。然后在较新的版本中(现在已经很旧了),它被移到了自己的包中。
下面的截图来说明这一点。
旧的:

较新版本:

截图显示了转换后的代码。
如果文档不清楚,请检查文档!https://reactjs.org/docs/typechecking-with-proptypes.html
https://stackoverflow.com/questions/52606918
复制相似问题