【发布时间】:2019-06-13 09:11:31
【问题描述】:
我有一个歌曲列表,单击按钮时会显示详细信息。现在我想单击另一个按钮来删除显示的详细信息。该函数是removeDescriptionReducer。我正在显示我的减速器文件。
reducers.js
import { combineReducers } from 'redux';
const songsReducer = () =>{
return [
{ title: 'No Scrubs', duration: '4:05'},
{ title: 'Macarena', duration: '3:55'},
{ title: 'All Stars', duration: '1:28'},
{ title: 'I want it that way', duration: '2:05'},
];
};
const selectedSongReducer = (selectedSong=null, action) => {
if(action.type === 'SONG_SELECTED'){
return action.payload;
}
return selectedSong;
}
const removeDescriptionReducer = (removeDescription=null, action) => {
if(action.type === 'REMOVE_DESCRIPTION'){
alert (action.payload);
}
return removeDescription;
}
export default combineReducers({
songs: songsReducer,
selectedSong: selectedSongReducer,
removeDescription: removeDescriptionReducer
});
【问题讨论】:
-
您能否进一步输入您在有效负载中收到的内容以及您到底想要什么,您想要返回一个包含所有条目(歌曲)的新状态,除了点击的条目或其他内容?
标签: redux react-redux redux-form