【发布时间】:2017-06-18 11:49:16
【问题描述】:
我们有一个带有这个OurController 项目的反应应用程序。 OurController 工作正常。从示例中添加以下代码会破坏整个应用程序,不会在浏览器中呈现任何页面:
const TextCell = ({rowIndex, data, col, ...props}) => (
<Cell {...props}>
{data.getObjectAt(rowIndex)[col]}
</Cell>
);
文件的开头是
var FixedDataTable = require('fixed-data-table');
var React = require('react');
const Table = FixedDataTable.Table;
const Column = FixedDataTable.Column;
const Cell = FixedDataTable.Cell;
const TextCell = ({rowIndex, data, col, ...props}) => (
<Cell {...props}>
{data.getObjectAt(rowIndex)[col]}
</Cell>
);
class OurDataTable extends React.Component {
一旦我将其注释掉,一切都很好,但我想尽可能地遵循教程
错误是这样的
Module build failed: SyntaxError: Unexpected token (10:40)
const TextCell = ({rowIndex, data, col, {issue is here}...props}) => (
带有指向...props的箭头,好像看不懂...(箭头指向第一个点)
指南是fixed-data-table的这个sn-p:
https://github.com/facebook/fixed-data-table/blob/master/examples/ObjectDataExample.js
我知道整个文件通常很重要,但我保证代码会按预期工作,直到添加 TextCell。我们有某些 babel loader,但我没有看到固定数据表要求更多:
var webpack = require('webpack');
module.exports = {
//devtool: 'inline-source-map',
entry: [
'webpack-hot-middleware/client',
'./client/main.js'
],
output: {
path: require("path").resolve('./public'),
filename: 'bundle.js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'react-hmre']
}
}
]
}
};
一个快速服务器同样配置并且正在工作(热重载等)
我们已经使用了 ES6 并且在类似的东西上工作
class OurDataTable extends React.Component {
等
【问题讨论】:
标签: javascript html facebook reactjs fixed-data-table