解決:我ADDED紗文件。我刪除了它,並且模塊THEN重做NPM安裝和它的工作...不完全知道那裏發生了什麼,但似乎這樣做。反應,和/ Redux的項目沒有評估括號ES6
編輯︰所以它結束了字符串內插不相關(使用單引號而不是後面的蜱 - 面掌)但病例陳述不能評估的問題仍然在大。
因此,我正在做Wes Bos的'Redux Course,這是非常酷的,我很喜歡它,即使它是非常快速地拍攝。
已經有一些極少數的事情,我需要在這裏和那裏更新,以得到它的工作。 (如我的主要組件中的這條線,沒有它熱重新加載根本不工作:module.hot.accept(),但它不在his files)
我還擴展了React.Component而不是使用.createClass來嘗試更加流行。否則,我的文件與上面鏈接的文件完全一樣。
我到約13日的視頻,我已經得到了完全停止了我一個問題,我不能讓過去,我只有大約一個可能是錯誤的想法,但我希望有人可以幫助。
首先,我覺得這其他更瑣碎的問題可能是相關的,我的組件將不會做字符串插值他的遺囑:
import React from 'react';
import { Link } from 'react-router';
import CSSTransitionGroup from 'react-addons-css-transition-group';
export default class Photo extends React.Component {
constructor(props) {
super(props);
}
render() {
const { post, index, comments } = this.props
return (
<figure className="grid-figure">
<div className="grid-photo-wrap">
<Link to={'/view/${post.code}'}>
<img className="grid-photo" src={post.display_src} alt={post.caption} />
</Link> ...
這完全適用於他除了這不會爲我工作。鏈接目標將無法評價,我將不得不使用:
<Link to={'/view/' + post.code}>
否則將href會出來這樣的:
http://localhost:7770/view/$%7Bpost.code%7D
沒能找到一個理由爲什麼不工作,我用了這個醜陋的字符串,然後繼續前進。但後來我打了一個停止的問題幾部影片後說給我的印象相似,可能是相關的,所以我問在這裏。
在他的第12視頻,他fleshes了帖子減速與此代碼:
function posts(state=[], action) {
switch(action.type) {
case 'INCREMENT_LIKES':
const index = action.index;
return [
...state.slice(0,index), // before what we are updating
{...state[index], likes: state[index].likes + 1},
...state.slice(index + 1), // after what we are updating
]
default:
return state;
}
}
export default posts;
這適用於他的預期。對我來說,根本不是。我得到:
5 | return [
6 | ...state.slice(0,index), // before what we are updating
> 7 | {...state[index], likes: state[index].likes + 1},
| ^
8 | ...state.slice(index + 1), // after what we are updating
9 | ]
10 | default:
我的猜測是,由於某種原因,在這兩種情況下注入ES6不被評估。雖然這兩個工作單獨在別處,因爲應用程序中的所有其他依賴注入JS或ES6直到這一點工作正常。例如,在第一示例post.display_src評價細括號內,由於是使用解構的恆定分配。所以我不知道罪魁禍首是括號內的ES6。但這是我唯一的想法,就我所能接受而言。希望有人能把我救出來,這樣我就可以繼續這個教程。
PS - 就像我說過的,除了上面提到的小改動之外,我的文件與他的文件基本相同。不過我會在這裏包括webpack.config.dev.js因爲我預計這可能是很多人的第一個停靠港的:
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: [
'webpack-hot-middleware/client',
'./client/rootMount'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
],
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'client'),
},
{
test: /\.styl$/,
include: path.join(__dirname, 'client'),
loader: 'style-loader!css-loader!stylus-loader'
}
]
}
};
而且。babelrc文件:
{
"presets": ["react", "es2015"],
"env": {
"development": {
"plugins": [
["transform-object-rest-spread"],
["transform-react-display-name"],
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}]
]
},
"production": {
"plugins": [
["transform-object-rest-spread"],
["transform-react-display-name"]
]
}
}
}
這應該是indes不索引? 'const index = action.indes;' – Brian
你有一個'.babelrc'文件嗎? – azium
PS它崩潰的語法不是ES6。這是一個階段3 propoasal可能進入ES8稱爲休息/傳播屬性https://github.com/tc39/proposals – azium