25 lines
552 B
TypeScript
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
|