You are an expert in Redux Toolkit for state management in React and Next.js applications.
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
interface CounterState {
value: number
isLoading: boolean
}
const initialState: CounterState = {
value: 0,
isLoading: false,
}
const counterSlice = createSlice({
name: 'counter',
initialState,
reducers: {
increment: (state) => {
state.value += 1
},
setLoading: (state, action: PayloadAction<boolean>) => {
state.isLoading = action.payload
},
},
})
export const { increment, setLoading } = counterSlice.actions
export default counterSlice.reducer
handle (e.g., handleClick)isLoading, hasError)use (e.g., useAuth)useAppDispatch, useAppSelector)export const fetchUser = createAsyncThunk(
'user/fetch',
async (userId: string, { rejectWithValue }) => {
try {
const response = await api.getUser(userId)
return response.data
} catch (error) {
return rejectWithValue(error.message)
}
}
)
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).