小编Gut*_*typ的帖子

找不到模块:错误:无法解析“ core-js / es6”

我的React应用程序的构建过程出现问题。

我总是收到以下错误:

找不到模块:错误:无法解析“ core-js / es6”

如果我在polyfill.js中使用它:

导入'core-js / es6';

那就是我的package.json:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "devDependencies": {
    "@babel/core": "^7.4.0",
    "@babel/preset-env": "^7.4.2",
    "@babel/preset-react": "^7.0.0",
    "@babel/runtime": "^7.4.2",
    "babel-loader": "^8.0.5",
    "babel-preset-es2015": "^6.24.1",
    "copy-webpack-plugin": "^5.0.2",
    "css-hot-loader": "^1.4.4",
    "eslint": "5.15.3",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-loader": "^2.1.2",
    "eslint-plugin-import": "2.16.0",
    "eslint-plugin-jsx-a11y": "6.2.1",
    "eslint-plugin-react": "7.12.4",
    "file-loader": "^3.0.1",
    "node-sass": "^4.11.0",
    "prettier": "^1.16.4",
    "react-hot-loader": "4.8.0",
    "sass-loader": "^7.1.0",
    "webpack": "^4.29.6",
    "webpack-cli": "^3.3.0",
    "webpack-dev-server": "^3.2.1"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "core-js": "^3.0.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.5",
    "react-dom": …
Run Code Online (Sandbox Code Playgroud)

build npm package.json yarnpkg

64
推荐指数
10
解决办法
4万
查看次数

NextJS - 导出被破坏(没有 CSS,没有 JS)

我正在使用 NextJS ( https://nextjs.org/ ) 9.0.6 版。

我的 next.config.js 看起来像这样:

/* eslint-disable */
const withLess = require("@zeit/next-less");
const lessToJS = require("less-vars-to-js");
const fs = require("fs");
const path = require("path");

// Where your antd-custom.less file lives
const themeVariables = lessToJS(
  fs.readFileSync(path.resolve(__dirname, "./assets/antd-custom.less"), "utf8")
);

module.exports = withLess({
  lessLoaderOptions: {
    javascriptEnabled: true,
    modifyVars: themeVariables // make your antd custom effective
  },
  webpack: (config, {
    isServer,
    defaultLoaders
  }) => {
    const originalEntry = config.entry;
    config.entry = async() => {
      const entries = await …
Run Code Online (Sandbox Code Playgroud)

html javascript yarnpkg next.js

10
推荐指数
3
解决办法
2082
查看次数

Redux - ReactJS 应用程序不会重新渲染(尽管 JSON.parse 用于新对象)

我有一个带有过滤器的 ReactJS 应用程序,并使用 RESET 函数来重置这些过滤器。

我也使用过:Redux、Redux Persist 和 React-router-dom。

如果我查看 Redux Devtools,它似乎有效。但是应用程序没有正确重新渲染,需要刷新 (f5)。

我想要实现的目标:用initialState 对象覆盖configuredFilters 对象。

这是我的根减速器:

const rootReducer = (state = initialState, action) => {
  let newState = state;
  if (action.type === 'RESET_FILTERS') {
    storage.removeItem('persist:configuredFilters');
    // eslint-disable-next-line no-param-reassign
    newState = { ...newState,
      configuredFilters: JSON.parse(JSON.stringify(initialState.configuredFilters))
    };
  }
  return appReducer(newState, action);
};
Run Code Online (Sandbox Code Playgroud)

这是差异(我之前配置了两个国家):

调用 RESET 操作后的差异

这是对象(如果页面已加载,则为初始状态):

redux 对象配置的过滤器

组件是用这个组件创建的:

/* eslint-disable max-len */
import React from 'react';
import { useSelector, shallowEqual, useDispatch } from 'react-redux';
import { Form, Select } from 'antd';
import PropTypes from …
Run Code Online (Sandbox Code Playgroud)

javascript reducers reactjs

10
推荐指数
1
解决办法
464
查看次数

Jest - 无法从'source-map-support.js'找到模块'source-map'

我有问题,我得到错误:

Cannot find module 'source-map' from 'source-map-support.js'
Ran all test suites matching /Foo-test/i.
T:\public_html\testProj>jest Foo-test
FAIL  //XXXX.de/XXXX/Users/XXX/public_html/testProj/src/__tests__/Foo-test.js
? Test suite failed to runtml/testProj/src/__tests__/Foo-test.js
Cannot find module 'source-map' from 'source-map-support.js'
at Resolver.resolveModule (T:/public_html/testProj/node_modules/jest-resolve/build/index.js:221:17)
Run Code Online (Sandbox Code Playgroud)

如果我尝试用Jest进行测试.

我的.babelrc看起来像这样:

{
  "presets": ["env", "react"],
  "sourceMaps": "both",
  "plugins": [
    "add-module-exports",
    "react-hot-loader/babel",
    "source-map-support"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我的package.json看起来像这样:

{
  "name": "testproject",
  "version": "1.8.0",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "devDependencies": {
    "@babel/runtime": "^7.0.0-rc.1",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.3",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "copy-webpack-plugin": "^4.5.2",
    "css-hot-loader": "^1.3.9",
    "eslint": "4.9.0",
    "eslint-config-airbnb": …
Run Code Online (Sandbox Code Playgroud)

testing reactjs jestjs

6
推荐指数
1
解决办法
2032
查看次数

Material UI 复选框 - 文本对齐

我正在使用 Material UI 4.8.3 并具有以下内容:

const CustomizedCheckbox = withStyles({
  root: {
    color: '#0f236e',
    '&$checked': {
      color: '#0f236e',
    },
  },
  checked: {},
})((props) => <Checkbox color="default" {...props} />);


<Grid
        item
        xs={12}
        sm={12}
        md={12}
        lg={12}
        className="disclaimerAndNotes"
      >
        <FormControl fullWidth>
          <FormControlLabel
            control={<CustomizedCheckbox />}
            label={<div className="disclaimerandnotes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd …
Run Code Online (Sandbox Code Playgroud)

javascript css material-ui

5
推荐指数
1
解决办法
2569
查看次数

无法读取未定义的属性“getState” - Redux

我有一个 React 应用程序,现在我使用 redux。该应用程序工作正常,但现在我收到错误:

Uncaught TypeError: Cannot read property 'getState' of undefined
    at new Provider (Provider.js:25)
    at vf (react-dom.production.min.js:132)
    at Og (react-dom.production.min.js:167)
    at Tg (react-dom.production.min.js:180)
    at bi (react-dom.production.min.js:232)
    at ci (react-dom.production.min.js:233)
    at Di (react-dom.production.min.js:249)
    at Yh (react-dom.production.min.js:248)
    at Xh (react-dom.production.min.js:245)
    at qf (react-dom.production.min.js:243)
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

代码:

商店.js:

Uncaught TypeError: Cannot read property 'getState' of undefined
    at new Provider (Provider.js:25)
    at vf (react-dom.production.min.js:132)
    at Og (react-dom.production.min.js:167)
    at Tg (react-dom.production.min.js:180)
    at bi (react-dom.production.min.js:232)
    at ci (react-dom.production.min.js:233)
    at Di (react-dom.production.min.js:249)
    at Yh (react-dom.production.min.js:248)
    at …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux

0
推荐指数
1
解决办法
6188
查看次数