State first routing
Set up the app
import { Action, AsyncAction } from 'overmind'
export const showHomePage: Action = ({ state }) => {
state.currentPage = 'home'
}
export const showUsersPage: AsyncAction = async ({ state, effects }) => {
state.modalUser = null
state.currentPage = 'users'
state.isLoadingUsers = true
state.users = await effects.api.getUsers()
state.isLoadingUsers = false
}
export const showUserModal: AsyncAction<{ id: string }> = async ({ state, effects }, params) => {
state.isLoadingUserDetails = true
state.modalUser = await effects.api.getUserWithDetails(params.id)
state.isLoadingUserDetails = false
}Initialize the router
The list of users
Composing actions
Imperative approach
Functional approach
The tab query param
Imperative approach
Functional approach
Summary
Last updated