减速器代码
function reducer(state, action) {
switch (action.type) {
case 'add':
return {selectedArr: initialState.selectedArr.push(action.payload)};
case 'all':
return {all: !initialState.all};
case 'remove':
return {
selectedArr: initialState.selectedArr.splice(
initialState.selectedArr.indexOf(action.payload),
1,
),
};
default:
throw new Error();
}
}
行动派遣
<TouchableRipple
onPress={() => dispatch({type: 'all'})}
rippleColor={Theme.colors.accent}
>
<Surface style={[styles.ptpListFilterSurface]}>
<Text>All</Text>
</Surface>
</TouchableRipple>
有人可以帮我解决为什么这种发送方式不起作用吗?其他调度工作完美