A
A
asdasdqwe2022-02-28 17:48:16
typescript
asdasdqwe, 2022-02-28 17:48:16

How to set a team for state in redux?

const cart = {
  products: (localStorage.getItem("cart") || []),
};

export const CartReduser = (state = cart, action: any) => {}


As a result, the error Object literal's property 'products' implicitly has an 'string | any[]' type.
How to set type for state? More precisely, for products

, localstorage simply returns an array of objects with id and name

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question