首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能需要React.js组件

不能需要React.js组件
EN

Stack Overflow用户
提问于 2015-04-19 03:05:51
回答 1查看 819关注 0票数 0

我正在尝试导入一个名为'fixed-data-table‘的React.js组件,但它在线路上出现了问题:

代码语言:javascript
复制
var FixedDataTable = require('fixed-data-table');

它抛出以下错误:

代码语言:javascript
复制
pez@pezbox:~/projects/react-server-example$ node server.js 
/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableValue.js:65
      Object.assign(destination, propertyObjects[i]);
             ^
TypeError: undefined is not a function
    at Function.ImmutableValue.mergeAllPropertiesInto (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableValue.js:65:14)
    at new ImmutableObject (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/ImmutableObject.js:50:20)
    at Object.<anonymous> (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/FixedDataTableCell.react.js:22:21)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/pez/projects/react-server-example/node_modules/fixed-data-table/internal/FixedDataTableCellGroup.react.js:19:26)

我使用以下命令安装了depedencies

sudo npm install

奇怪的是,如果由于访问权限而排除sudo,它将不起作用。

有什么不对劲的地方吗?

EN

回答 1

Stack Overflow用户

发布于 2015-04-20 03:50:04

您需要导入object-assign

这就是你的错误

代码语言:javascript
复制
Object.assign(destination, propertyObjects[i]);
       ^
TypeError: undefined is not a function

您可以像这样导入object-assign

代码语言:javascript
复制
/** @jsx React.DOM */
var assign = require('object-assign');

首先,您可能希望使用npm install安装它。下面是我使用的package.json。请注意object-assign

代码语言:javascript
复制
{
  "name": "gae-react-flux-todos",
  "version": "0.0.1",
  "description": "A simple TODOS app in React and Flux, built on top of Google App Engine",
  "author": "Ben Grunfeld",
  "repository": "https://github.com/bengrunfeld/gae-react-flux-todos",
  "readme": "https://github.com/bengrunfeld/gae-react-flux-todos/blob/master/README.md",
  "license": "Apache 2",
  "devDependencies": {
    "gulp": "^3.8.11",
    "gulp-browserify": "^0.5.0",
    "gulp-clean": "^0.3.1",
    "gulp-concat": "^2.2.0",
    "gulp-react": "^2.0.0",
    "gulp-replace": "^0.5.3",
    "browserify": "^9.0.3",
    "react": "^0.12.2",
    "reactify": "^0.13.1",
    "es6-promise": "^1.0.0",
    "flux": "^2.0.1",
    "object-assign": "^1.0.0",
    "jest-cli": "^0.4.0",
    "react-tools": "^0.12.0",
    "classnames": "1.2.0"
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29721581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档