Answer the question
In order to leave comments, you need to log in
How to properly pass data to React Redux TypeScript?
There is an array of objects, you need to make sure that when the onClick event occurs, the object is added to a specific array.
types.ts
export interface ImagesState {
images?: any[];
loading?: boolean;
error?: null | string;
page?: number;
limit?: number;
pages?: any[];
selected?: any[];
current?: null | object;
}
interface SetImagesSelected {
type: ImagesActionTypes.SET_IMAGES_SELECTED,
payload: object
}
export type ImagesAction = SetImagesSelected
export const setImagesSelected = (current: object): ImagesAction => {
return {type: ImagesActionTypes.SET_IMAGES_SELECTED, payload: current}
}
case ImagesActionTypes.SET_IMAGES_SELECTED:
return {...state, selected: [...action.payload]}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question