【发布时间】:2019-12-23 10:35:08
【问题描述】:
大家好,我正在尝试学习 redux,在我的组件中我有一个值,需要将它传递给我的 reducer。
这是我的组件:
import React from "react";
import Iframe from "react-iframe";
import { Row, Col, Card} from "react-bootstrap";
import {connect} from 'react-redux';
import TextsInput from "./TextsInput";
import ImagesInput from "./ImagesInput";
import Aux from "../../hoc/_Aux";
class Frames extends React.Component {
render() {
return (
<Aux>
<Col md={7}>
<Iframe
url={this.props.url}
width= {this.props.width}
height= {this.props.height}
id= {this.props.id}
/>
{this.props.inputs.map(( i, index) =>
<TextsInput
key={i.index}
id={i.id}
name={i.name}
placeholder={i.placeholder}
newText={i.newText}
clicked={this.props.handleChange}
/>)}
</Col>
</Aux>
);
}
}
const mapDispatchToProps = dispatch => {
return {
handleChange: () => dispatch({type: 'NEWINPUT'})
}
};
export default connect(mapDispatchToProps)(Frames);
我想将 frame id 发送到我的 reducer,我该怎么做? 谢谢大家
【问题讨论】:
标签: reactjs react-redux reduce