currentPoiSlice als Redux Slice implementiert statt Recoil atom

This commit is contained in:
ISA
2024-12-18 21:44:41 +01:00
parent 2934565501
commit b5571989ba
7 changed files with 52 additions and 36 deletions

View File

@@ -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;

View File

@@ -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,
});