Error: Missing class properties transform
Test.js
:
export class Test extends Component {
constructor (props) {
super(props)
}
static contextTypes = {
router: React.PropTypes.object.isRequired
}
Run Code Online (Sandbox Code Playgroud)
.babelrc
:
{
"presets": ["es2015", "react", "stage-0"],
"plugins": ["transform-class-properties"]
}
Run Code Online (Sandbox Code Playgroud)
package.json
:
"babel-core": "^6.5.1",
"babel-eslint": "^4.1.8",
"babel-loader": "^6.2.2",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.5.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.5.2",
Run Code Online (Sandbox Code Playgroud)
我已经浏览了网页并且所有修复都围绕着:升级到babel6,将"stage-0"的顺序切换为"es2015"之后.我所做的一切.
我希望能够在使用jest时使用webpack别名来解析导入,并且最佳地引用它webpack.aliases
以避免重复.
Jest conf:
"jest": {
"modulePaths": ["src"],
"moduleDirectories": ["node_modules"],
"moduleNameMapper": {
"^@shared$": "<rootDir>/shared/",
"^@components$": "<rootDir>/shared/components/"
}
},
Run Code Online (Sandbox Code Playgroud)
Webpack别名:
exports.aliases = {
'@shared': path.resolve(paths.APP_DIR, 'shared'),
'@components': path.resolve(paths.APP_DIR, 'shared/components'),
};
Run Code Online (Sandbox Code Playgroud)
进口:
import Ordinal from '@shared/utils/Ordinal.jsx';
import Avatar from '@components/common/Avatar.jsx';
Run Code Online (Sandbox Code Playgroud)
由于某种原因@
导致问题,所以当删除(在别名和导入中)时,它可以找到shared
但components
仍然无法解决.
FAIL src/shared/components/test/Test.spec.jsx
? Test suite failed to run
Cannot find module '@shared/utils/Ordinal.jsx' from 'Test.jsx'
Run Code Online (Sandbox Code Playgroud)
我尝试过使用jest-webpack-alias,babel-plugin-module-resolver和Jest/Webpack docs
我正在运行一个快速服务器,它将充当我的React应用程序的API,该应用程序由webpack-dev-server捆绑并提供服务.
我正在尝试让热模块替换工作,并且几乎在那里,当我对我的文件进行更改时,我在控制台中得到了这个:
但除非手动刷新,否则永远不会重新渲染应用程序.不知道这是否相关,但是当我更新我的.scss
文件时,它会刷新而不会手动这样做,并且更新如我所料.
版本:
"webpack": "2.1.0-beta.22"
"webpack-dev-server": "2.1.0-beta.8"
"react-hot-loader": "3.0.0-beta.5"
我尝试了最新的webpack,但它给了我无法克服的验证错误.
我通过:运行webpack "webpack": "webpack-dev-server --port 4000 --env.dev"
,我的快速服务器正在运行http://localhost:3000
.
这是我的webpack.config.babel.js
:
const webpack = require('webpack');
const { resolve, join } = require('path');
const { getIfUtils, removeEmpty } = require('webpack-config-utils')
const getEntry = (ifDev) => {
let entry
if (ifDev) {
entry = {
app: [
'react-hot-loader/patch',
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:4000/',
'./js/index.js'
],
vendor: ['react']
}
} else {
entry = {
bundle: './js/index.js',
vendor: ['react']
}
}
return …
Run Code Online (Sandbox Code Playgroud) javascript webpack webpack-dev-server webpack-hmr hot-module-replacement
我有一个快速服务器处理:1 API路由和渲染我的初始index.html
包括bundle.js
我的React/React-Router/Redux应用程序.
就目前而言,我的网页上不可能有404,因为我有一个全部:
app.use(function (req, res) {
return res.render('index')
})
Run Code Online (Sandbox Code Playgroud)
为了让react-router
的NoMatch
工作,我需要发送一个404码.
我的路线如下:
表达 - /api/test/:x/:y
反应路由器 - :x/
,:x/:y
我本来想要实现的是,如果用户曾经访问过的URL::x/:y/z/and/further
然后返回404,除非他们去过的是/api/test/:x/:y
问题:
javascript node.js http-status-code-404 express react-router
我正在尝试获取 3 个单独的整数输入(年、月、日),并获取这 3 个条目并从中形成一个日期对象,以便我可以使用它来比较其他日期。
这是我到目前为止所拥有的,不知道从这里去哪里:
public void compareDates() {
String dayString = txtOrderDateDay.getText();
String monthString = txtOrderDateMonth.getText();
String yearString = txtOrderDateYear.getText();
int day = Integer.parseInt(dayString);
int month = Integer.parseInt(monthString);
int year = Integer.parseInt(yearString);
}
Run Code Online (Sandbox Code Playgroud)
非常感谢您提供的任何帮助。
尝试设置以下环境:
server.js
:创建服务器时,它将检查是否存在一系列文件:[api.log,error.log,access.log],如果它们尚不存在,则会创建它们.
routes/api.js
:我可以使用在启动时创建的文件,在api错误上记录错误.
很多建议都围绕着现在已弃用的fs.exists().
我正在努力拼凑事件的顺序,server.js
检查文件,采取相应的行动,然后打开一个流?或者必须routes/api.js
打开流并在每个错误上写入它?
我使用的是Node v5.0.0
Procfile:
build: npm run prod
web: nodemon server.js
Run Code Online (Sandbox Code Playgroud)
的package.json
"scripts": {
"prod": "NODE_ENV=production webpack -p --config ./webpack.prod.config.js --progress --optimize-dupe"
}
Run Code Online (Sandbox Code Playgroud)
Webpack.prod.config:
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: null,
entry: [
'./assets/js/index'
],
output: {
path: path.join(__dirname, 'public/dist/'),
filename: 'bundle.js',
publicPath: '/public/'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env': { NODE_ENV: '"production"' }
})
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个OOP友好的Java BlackJack游戏来提升我的知识.
我碰壁了,我只是不知道看到问题.想知道是否有人能指出我的问题.
此外,在谷歌搜索相关主题后,我发现人们一次又一次地说使用枚举会更有益,因为初学者会建议吗?或者我应该暂时坚持使用String数组.
谢谢.
我的代码:
public class BlackJack{
BlackJack() {
Deck deck = new Deck();
deck.createDeck();
System.out.println(deck.deckList);
}
public static void main(String[] args) {
new BlackJack();
}
}
public class Card{
private String valueCard;
private String suitCard;
public Card(String value, String suit) {
this.valueCard = value;
this.suitCard = suit;
}
public String getValue() {
return valueCard;
}
public String getSuit() {
return suitCard;
}
}
import java.util.ArrayList;
public class Deck {
ArrayList<Card> deckList = new ArrayList<Card>();
String[] value = …
Run Code Online (Sandbox Code Playgroud) 我是c ++的新手,并且在星期天凌晨1点在一个回文程序中进行屠宰,因为!我遇到过这个问题:
输入:test反向:tset3-F
3-F来自哪里?有时它只是-F或其他数字-F.这是从哪里来的?
这是我的代码:
#include <iostream>
#include <string>
using namespace std;
int main() {
string eString;
int length;
int counter = 0;
cout << "Enter String: ";
cin >> eString;
length = eString.length();
char reverseChar[length];
for(int x = eString.length() -1; x > -1; x--) {
reverseChar[counter] = eString[x];
counter++;
}
cout << "Reverse: " << reverseChar;
}
Run Code Online (Sandbox Code Playgroud)
非常感谢你的时间.
我试图从组合框中检索一个值,并使用列表将其放入另一个组合框.
我成功地从列表中删除了值,并将其实现到其他列表中.但是当我这样做时,我的列表容量出现故障,并且我得到了索引超出范围的错误.
场景:
列出的信件选择:B
'左移按钮按下'
'B'已从信件列表中删除
'B'已添加到Numbers List
打印输出值
错误:"索引超出范围.必须是非负数且小于集合的大小
第66行:Console.WriteLine("Numbers:"+ numbers [i] +"\ tIteration:"+ i);
号码列表容量:8,字母列表容量:4.
编号列表:1,2,3,4,B.字母列表:A,C,D
码:
public partial class Form1 : Form
{
public List<string> letters = new List<string>();
public List<string> numbers = new List<string>();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
InitialiseLists();
LoadListsIntoCombo();
}
public void InitialiseLists()
{
/*
* Add Letter Data
*/
letters.Add("A");
letters.Add("B");
letters.Add("C");
letters.Add("D");
/*
* Add Number Data
*/
numbers.Add("1");
numbers.Add("2");
numbers.Add("3");
numbers.Add("4");
}
public void …
Run Code Online (Sandbox Code Playgroud)