我正在尝试通过 Babel 使用 JSPM 和 ES6 为 React 设置 Material UI。
1)安装material-ui与jspm install material-ui=npm:material-ui
2)这使我能够将材料 ui 导入到我的 React 组件文件中,如下所示:import {TextField, LeftNav} from 'material-ui'
在这一点上,我在我的 ES6 文件中得到了正确的引用,所以如果我做一个 console.log(TextField); 我打印了反应组件。
可悲的是,我当前的问题是尝试在 jsx 中使用该组件时遇到错误
return (
<div>
<TextField />
</div>
)
引发错误:
Warning: getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.
warning.js:17 Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory
warning.js:26 Warning: TextField(...): No `render` method found on the returned component instance: you may have forgotten to define `render` in your component or you may have accidentally tried to render an element whose type is a function that isn't a React component.
warning.js:17 Warning: Don't set the props property of the component. Mutate the existing props object instead.
dashboard:1 Uncaught (in promise) Error: Can't add property context, object is not extensible
Error loading http://localhost:3000/app.js
at ReactCompositeComponentMixin.mountComponent
根据警告,我认为该错误可能是由工具组合 Babel+JSPM+Material-UI 创建的特定情况引起的。