traintrape-moi/client/utils/features/location/locationSlice.ts

25 lines
552 B
TypeScript

import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { LocationObject } from 'expo-location'
interface LocationState {
location: LocationObject | null
}
const initialState: LocationState = {
location: null
}
export const locationSlice = createSlice({
name: 'location',
initialState: initialState,
reducers: {
setLocation: (state, action: PayloadAction<LocationObject>) => {
state.location = action.payload
},
},
})
export const { setLocation } = locationSlice.actions
export default locationSlice.reducer