相关疑难解决方法(0)

警告:失败的 propType:在 `DimensionPicker` 中未指定必需的 prop `dimensionName`。检查`Connect(DimensionPicker)`的渲染方法

我有以下 Redux+React 组件

import {PropTypes, React, Component} from 'react';
import Select from 'react-select';

class DimensionPicker extends Component {
    componentDidMount() {
        const {onLoad} = this.props;
        onLoad();
    }
    render() {
        const {onChange, attributeList, currentAttribute} = this.props;
        return (
            <div>
                <Select value={currentAttribute} options={attributeList} onChange={onChange} />
            </div>
        )       
    }
}

DimensionPicker.propTypes = {
    dimensionName: PropTypes.string.isRequired,
    onChange: PropTypes.func.isRequired,
    attributeList: PropTypes.arrayOf(PropTypes.shape({
        value: PropTypes.string.isRequired,
        label: PropTypes.string.isRequired
    }).isRequired).isRequired,
    currentAttribute: PropTypes.string.isRequired
}

export default DimensionPicker;
Run Code Online (Sandbox Code Playgroud)

以及以下容器组件

import React from 'react';
import DimensionPickerActions from '../actions/DimensionPickerActions';
import {connect} from 'react-redux';
import …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-redux

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

标签 统计

javascript ×1

react-redux ×1

reactjs ×1

redux ×1