I have following action in redux action.js file,
export const removeActiveLayer = (id) => (dispatch) => {
dispatch({
type: REMOVE_ACTIVE_LAYER,
payload: id,
});
};
my reducer.js file is as below,
case REMOVE_ACTIVE_LAYER:
return {
...state,
activeLayers: state.activeLayers.filter((l) => action.payload !== l.id),
};
I tried to remove the layer from the RemoveLayer.js file as below,
this.props.removeLayer(55);
The layer is removed successfully. There is no issue. My question is, How can I get that id=55 from another file Layers.js?
I have tried to get it in ComponentDidUpdateProps as below,
componentDidUpdate(prevProps, prevState) {
const { removeActiveLayer } = this.props;
if (removeActiveLayer) {
console.log(removeActiveLayer);
}
}
It is just a function, but actually, I need a removed id. Any help will be highly appreciated.