我越来越
script.js:11 Uncaught TypeError: __webpack_require__.i(...) is not a function
at Object.<anonymous> (http://localhost:8000/js/main.723b6bbbc5e319d89909.js:13057:107)
at __webpack_require__ (http://localhost:8000/js/main.723b6bbbc5e319d89909.js:20:30)
at Object.<anonymous> (http://localhost:8000/js/main.723b6bbbc5e319d89909.js:31776:18)
at __webpack_require__ (http://localhost:8000/js/main.723b6bbbc5e319d89909.js:20:30)
at http://localhost:8000/js/main.723b6bbbc5e319d89909.js:64:18
at http://localhost:8000/js/main.723b6bbbc5e319d89909.js:67:10
Run Code Online (Sandbox Code Playgroud)
13057行是:
var browserHistory = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6_react_router__["useRouterHistory"])(__WEBPACK_IMPORTED_MODULE_8_history_createBrowserHistory___default.a)({
basename: ''
});
Run Code Online (Sandbox Code Playgroud)
这是源映射自
import {createStore, combineReducers} from 'redux';
import {syncHistoryWithStore, routerReducer} from 'react-router-redux';
import {useRouterHistory} from 'react-router';
import createBrowserHistory from 'history/createBrowserHistory';
const browserHistory = useRouterHistory(createBrowserHistory)({
basename: ``
});
const store = createStore(
combineReducers({
chat, routing: routerReducer
})
);
const history = syncHistoryWithStore(browserHistory, store);
Run Code Online (Sandbox Code Playgroud)
我在“useRouterHistory”上出现红色下划线,有什么想法吗?
这是我的 webpack.config.js 文件,我认为这会干扰我正在编写的代码
// changed …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用webpack 2实现extract-text-webpack-plugin,我正在从头开始构建我的webpack.config.js.当我想添加插件时,我按照npm上的说明操作.但是这给了我以下错误:
TypeError: Cannot read property 'query' of undefined
我环顾四周,没有抓到其他人对此插件有同样的问题.在假设这是一个错误之前,我宁愿先问我是否犯了错误.
我的webpack.config.js是
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: path.resolve(__dirname, './src'),
entry: {
app: './main.js',
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: { presets: ['es2015'] }
}]
},
{
test: /\.(sass|scss)$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
]
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: …Run Code Online (Sandbox Code Playgroud) 我正在调用操作requestLoadOrders来获取我需要的订单。我用 type: 分派,REQUEST然后用SUCCESSor分派FAILURE。获取成功是因为我的订单位于 redux dev-tools 的有效负载中,但我在减速器中收到的操作是@@redux/PROBE_UNKNOWN_ACTION_z.r.p.l.z. 我在这里找到了一个线程,但是我似乎找不到我做错了什么?
动作.js
import {
LOAD_ORDERS_REQUEST,
LOAD_ORDERS_SUCCESS,
LOAD_ORDERS_FAILURE
} from './constants';
import { fetchOrders } from '../../api';
export const requestLoadOrders = () => {
return (dispatch, getState) => {
dispatch({ type: LOAD_ORDERS_REQUEST });
fetchOrders().then(orders => {
dispatch({ type: LOAD_ORDERS_SUCCESS, payload: orders });
}).catch(error => {
console.error(error);
dispatch({ type: LOAD_ORDERS_FAILURE, payload: error });
});
};
};
Run Code Online (Sandbox Code Playgroud)
减速器.js
import {
LOAD_ORDERS_REQUEST,
LOAD_ORDERS_SUCCESS,
LOAD_ORDERS_FAILURE
} from …Run Code Online (Sandbox Code Playgroud) 我想要实现的目标:使用 Express JS 制作的可以获取数据的路由(例如来自:https : //tmi.twitch.tv/group/user/instak/chatters),通过 React Router 将其发送到我正确的路由并让 React 等待数据被获取,这样我就可以使用该数据与客户端一起工作。
我试过的
服务器.js
'use strict';
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(path.resolve(__dirname, '..', 'instakbot-client')));
// Always return the main index.html, so react-router render the route in the client
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'instakbot-client', 'index.html'));
});
app.get('/home', (req, res) => {
res.send("I'm just testing to see if this works");
});
const PORT = process.env.PORT || 8000;
app.listen(PORT, () => …Run Code Online (Sandbox Code Playgroud) reactjs ×3
redux ×2
webpack ×2
express ×1
javascript ×1
node.js ×1
react-redux ×1
react-router ×1
webpack-2 ×1