动态生成选择的选项?

时间:2019-07-18 11:39:18

标签: node.js reactjs select redux

我尝试为选择生成可疑的表情。

所以我用redux调度来影响数据。 然后我进入componentDidmount 我尝试通过接收的选项标签来选择

import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Redirect } from 'react-router-dom'
import { getAllPartition } from '../../Store/Actions/partitionAction'

class Dashboard extends Component {
    state = {
        partition: '',
        mode: '',
    }

    componentDidMount() {
        this.props.dispatch(getAllPartition())
    }

    render() {
        const { auth, partition } = this.props

        if (auth.logIn === false) {
            return <Redirect to='/connexion'/>
        }

    return (
        <div className="dashboard container">
            <form onSubmit={this.handleSubmit} className="white">
            <div className="input-field col s12">
                <select id="partition" onChange={this.handleChange}>
                    {
                        (partition.partition).map(obj => 
                            <option key={obj._id}
                            value={obj._id}>
                            {obj.name}</option>    
                        )
                </select>
            </div>
            </form>
        </div>
    )
    }
}

const mapStateToprops = (state) => {
    return {
        consigne: state.consigne.consigne,
        auth: state.auth,
        partition: state.partition
    }
}

export default connect(mapStateToprops)(Dashboard)

我很高兴看到我的领域,我可以在这里隐蔽,但什么也没显示。我有一个空白页。

0 个答案:

没有答案