1

我无法将 React 插件与 JSPM 一起使用,但 React 本身正在运行。JSPM 抛出此错误:

Potentially unhandled rejection [3] Error loading "react-addons-{addon}" at http://localhost:3000/react-addons-{addon}.js

当我尝试在我的项目中使用 Material-UI 时会出现此问题。

4

2 回答 2

0

我从来没有遇到过这个问题,但我有另一个问题。我的设置是:

  • jspm
  • ES6 的通天塔

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 

也许这会帮助人们摆脱这个问题。

于 2015-08-23T21:39:56.667 回答
0

我认为这是可以解决import React from 'react/lib/ReactWithAddons'的问题,因为基本上你从 lib 加载该文件,但我认为 React 会删除这些插件并为它们创建一些 npm 包。我真的不知道为什么,所以我希望这至少对你有用,现在。

更多信息:

于 2015-07-21T10:08:15.297 回答