简体   繁体   English

<grid>和<row>标签在反应中不起作用,给出错误:bundle.js:9 错误:缩小反应错误 #130</row></grid>

[英]<Grid> and <Row> tags not working in react giving error : bundle.js:9 Error: Minified React error #130

I am developing a sample react-redux application using webpack我正在使用 webpack 开发示例 react-redux 应用程序

webpack.config.js webpack.config.js

var path=require('path');
const webpack = require('webpack'); 
module.exports= {
    entry : './src/app.js',
    output : {
        filename : 'bundle.js',
        path : path.resolve(__dirname,'public')
    },
    watch: true,
    module : {
        rules : [
            {
                test :/\.js$/,
                exclude: /node_modules/,
                loader : 'babel-loader',
                query : {
                    "presets": ["@babel/preset-env","@babel/preset-react"]
                }
            }
        ]
    }
}

bookList.js bookList.js

"use strict"
import React from 'react';
import {connect} from 'react-redux';
import { bindActionCreators } from 'redux';
import {getBooks} from '../../actions/booksAction';
import {Grid, Col, Row, Button} from 'react-bootstrap';
import bookItem from './bookItem';
class BooksList extends React.Component
{
    componentDidMount(){
    this.props.getBooks()
    }

    render()
    {   
        const booksList = this.props.books.map((booksArr)=> {
            return (
                    <Col xs={12} sm={6} md={4} key={booksArr.id}>
                       testing
                    </Col>
                    )
        })


    return (
            <Grid>
                   {booksList} 
            </Grid>   
            )
    }
}

function mapStateToProps(state){
    // which data to pass to react component
  return{
    books: state.books.books
  }
}
function mapDispatchToProps(dispatch){
  return bindActionCreators({getBooks:getBooks}, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(BooksList);

index.html (main page where grid also will load) index.html(网格也将加载的主页)

<html>
    <head>
        <title>
        Hello Redux
        </title>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"  crossorigin="anonymous">
    </head>

    <body>
        <div id="root"></div>
    </body>    
    <script src="bundle.js"></script>
</html>

error bundle.js:9 Error: Minified React error #130;错误bundle.js:9 错误:缩小反应错误 #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.访问https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]=获取完整消息,或使用非精简开发环境获取完整错误和其他有用的警告。 (bundle.js:9) (bundle.js:9)

I already installed bootstrap, should i need to write anything in webconfig?我已经安装了引导程序,是否需要在 webconfig 中编写任何内容? Can anyone resolve my issue谁能解决我的问题

I have tried to add 'style-loader','css-loader' in presets of webconfig.js but giving error我试图在 webconfig.js 的预设中添加 'style-loader'、'css-loader' 但给出错误

I'd recommend not using bindActionCreator , the docs also recommend not using it with redux .我建议不要使用bindActionCreator文档也建议不要将它与redux一起使用。 It's misleading because the examples in the redux docs are a bit outdated and still use bindActionCreator .这是误导性的,因为 redux 文档中的示例有点过时并且仍然使用bindActionCreator More on that can be found here .更多信息可以在这里找到。

In your case, since you're already importing your action, you don't need to use the bindActionCreator .在您的情况下,由于您已经在导入您的操作,因此您不需要使用bindActionCreator You can simply do the below您可以简单地执行以下操作

function mapStateToProps(state){
    // which data to pass to react component
  return{
    books: state.books.books
  }
}

export default connect(mapStateToProps, {getBooks})(BooksList);

As for the error you're getting it's because one of the Components you tried to use is undefined.至于您收到的错误是因为您尝试使用的组件之一是未定义的。 I noticed you're using Grid , try using another component in bootstrap's library .我注意到您正在使用Grid ,请尝试使用 bootstrap's library中的另一个组件。 In the grid docs , you can try using a combination of Container , Row , and Col to create a grid system.网格文档中,您可以尝试使用ContainerRowCol的组合来创建网格系统。 See below.见下文。

<Container fluid="md">
  <Row>
    <Col>1 of 1</Col>
  </Row>
</Container>

If this is still creating issues try doing it with a div and see if it works.如果这仍然会产生问题,请尝试使用div执行此操作,看看它是否有效。 The undefined components could be a result of a dependency version mismatch.未定义的组件可能是依赖版本不匹配的结果。 You could potentially try deleting your node_modules and re-installing react-bootstrap.您可能会尝试删除您的node_modules并重新安装react-bootstrap.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的错误:缩小的React错误#130 - Uncaught Error: Minified React error #130 使用 react-table 时缩小 React 错误 #130 - Minified React error #130 when using react-table 反应-不断违反:最小化反应错误#130。 仅在生产中 - React - Invariant Violation: Minified React error #130. ONLY in Production bundle.js 而不是 React 组件上的控制台日志记录错误 - Console logging error on bundle.js instead of React component magento bundle.js错误 - magento bundle.js error 错误:缩小的 React 错误 #130:元素类型无效:预期为字符串或类/函数,但得到:未定义 - Error: Minified React error #130: Element type is invalid: expected a string or a class/function but got: undefined 错误 404 bundle.js not found - Spring 数据 Rest 和 React.js - Error 404 bundle.js not found - Spring Data Rest and React.js NodeJS和React:生成了bundle.js,但是我收到错误404(无法加载资源) - NodeJS and React: bundle.js is generated but I get error 404 (failure to load resource) 加载bundle.js(Http / Https)时反应混合内容错误 - React Mixed content error while loading bundle.js (Http/ Https) React.js错误:不变违规:Minified React错误#37 - React.js Error: Invariant Violation: Minified React error #37
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM