在一个屏幕(名为LCL_Active)上,我显示了一个用户列表。一旦选择了用户,用户的信息(作为道具传递)将显示在下一个屏幕上(名为LCL_Active_Details)。我创建的动作是(LCL_ActiveSelectedShipment)。我的减速机叫做(物品)。 目前,当我点击其中一个用户时,信息不会显示在下一个屏幕上。但是,正如你在我的reducer中看到的那样,我有一个console.log命令来捕获被点击的用户......这个console.log工作正在捕获信息。但是,当尝试将这些道具传递给LCL_Active_Details时,没有显示道具信息
REDUCER(项目):
MATCH (u)-[r]->(v)
WHERE (u)<--(v)
RETURN u, r, v
} }
行动(LCL_ActiveSelectedShipment):
export function items(state = [], action) {
switch (action.type) {
case 'ITEMS_FETCH_DATA_SUCCESS':
return action.payload;
case 'FETCH_USERS_SELECTED':
return action.payload;
default:
return state;
屏幕显示用户列表并识别用户点击:
export const LCL_ActiveSelectedShipment = (item) => {
const action = {
type: FETCH_USERS_SELECTED,
payload: item
}
console.log("You clicked on user:", item.name);
return action
};
显示选定用户的屏幕:
class LCL_Active extends Component {
import LCLActiveList from "../../../components/detailsLayout";
componentDidMount() {
this.props.fetchData('https://jsonplaceholder.typicode.com/users');
}
render() {
return (
<Container>
<Header style={styles.MainContainer} hasTabs>
<Body>
<Title>LCL</Title>
</Body>
<Right />
</Header>
<Content padder>
<LCLActiveList items={this.props.items}
LCL_ActiveSelectedShipment{this.props.LCL_ActiveSelectedShipment}
navigation {this.props.navigation}/>
</Content>
</Container>
);
}
}
function mapStateToProps(state) {
return {
LCL_ActiveSelectedShipment:state.LCL_ActiveSelectedShipment,
items: state.items,
};
}
function matchDispatchToProps(dispatch) {
return {
fetchData: (url) => dispatch(itemsFetchData(url)),
LCL_ActiveSelectedShipment: (item) =>
dispatch(LCL_ActiveSelectedShipment(item))
}
}
export default connect(mapStateToProps, matchDispatchToProps
(LCL_Active);