A
A
Alexander Show2020-10-16 18:22:15
typescript
Alexander Show, 2020-10-16 18:22:15

How to type reducer?

const initialState = {
    board: [
        {
            id: 23,
            title: "I am board",

        }
    ]
}


How to type this construction???

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Loli E1ON, 2020-10-16
@AlexShow163

type Board = {
    id: number;
    title: string;
}

type State = {
    board: Board[]
}

const initialState: State = {
    board: [
        {
            id: 23,
            title: "I am board",

        }
    ]
}

W
WbICHA, 2020-10-16
@WblCHA

It would seem that only 2 words: typescript+ reducer.
And already at the very first link, off-line documentation on this topic pops up: https://redux.js.org/recipes/usage-with-typescript

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question