currentPoiSlice als Redux Slice implementiert statt Recoil atom
This commit is contained in:
@@ -1,7 +1,28 @@
|
||||
// /redux/slices/currentPoiSlice.js
|
||||
import { atom } from 'recoil';
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
export const currentPoiState = atom({
|
||||
key: 'currentPoiState', // Eindeutiger Key, der dieses Atom identifiziert
|
||||
default: null, // Standardwert ist null oder ein leeres Objekt, je nach Bedarf
|
||||
const initialState = {
|
||||
currentPoi: null, // Standardwert wie im Recoil-Atom
|
||||
};
|
||||
|
||||
const currentPoiSlice = createSlice({
|
||||
name: "currentPoi",
|
||||
initialState,
|
||||
reducers: {
|
||||
setCurrentPoi(state, action) {
|
||||
state.currentPoi = action.payload; // Zustand mit dem neuen POI aktualisieren
|
||||
},
|
||||
clearCurrentPoi(state) {
|
||||
state.currentPoi = null; // Zustand auf null zurücksetzen
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Actions exportieren
|
||||
export const { setCurrentPoi, clearCurrentPoi } = currentPoiSlice.actions;
|
||||
|
||||
// Selector exportieren (optional)
|
||||
export const selectCurrentPoi = (state) => state.currentPoi.currentPoi;
|
||||
|
||||
// Reducer exportieren
|
||||
export default currentPoiSlice.reducer;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// /redux/slices/poiLayerVisibleStateSlice.js
|
||||
// Recoil atom for the visibility of the POI layer
|
||||
import { atom } from "recoil";
|
||||
|
||||
export const poiLayerVisibleState = atom({
|
||||
key: "poiLayerVisibleState",
|
||||
default: true,
|
||||
});
|
||||
Reference in New Issue
Block a user