Size: a a a

2020 September 19

t

th.witness in pro.js
let tempCart = [...this.state.cart]
       const selectedProduct = tempCart.find(item => item.id === id)

       const index = tempCart.indexOf(selectedProduct)
       const product = tempCart[index]
источник

t

th.witness in pro.js
@highthroughts, что здесь происходит?
источник

CM

Chingiz Mamiyev in pro.js
th.witness
@highthroughts, что здесь происходит?
Поиск товара по id
источник

CM

Chingiz Mamiyev in pro.js
источник

CM

Chingiz Mamiyev in pro.js
А вот снизу не понятно
источник

t

th.witness in pro.js
th.witness
let tempCart = [...this.state.cart]
       const selectedProduct = tempCart.find(item => item.id === id)

       const index = tempCart.indexOf(selectedProduct)
       const product = tempCart[index]
Ты находишь элемент в tempCart с некоторым айды, находишь его индекс в tempCart и вытаскиваешь элемент с tempCart с этим индексом и засовываешь в product.
источник

t

th.witness in pro.js
Chingiz Mamiyev
Поиск товара по id
Приглядись.
источник

t

th.witness in pro.js
th.witness
let tempCart = [...this.state.cart]
       const selectedProduct = tempCart.find(item => item.id === id)

       const index = tempCart.indexOf(selectedProduct)
       const product = tempCart[index]
Равносильный код:

const product = tempCart.find((item) => item.id === id)
источник

t

th.witness in pro.js
источник

CM

Chingiz Mamiyev in pro.js
th.witness
Равносильный код:

const product = tempCart.find((item) => item.id === id)
+
источник

CM

Chingiz Mamiyev in pro.js
А - аптимизация
источник

t

th.witness in pro.js
let tempProducts = []
       storeProducts.forEach(item => {
           const singleItem = { ...item }
           tempProducts = [...tempProducts, singleItem]
       })
источник

t

th.witness in pro.js
Редьюс:
источник

t

th.witness in pro.js
источник

CM

Chingiz Mamiyev in pro.js
Он не работает
источник

CM

Chingiz Mamiyev in pro.js
То что из текста делает скриншот с подсветкой
источник

CM

Chingiz Mamiyev in pro.js
источник

t

th.witness in pro.js
th.witness
let tempCart = [...this.state.cart]
       const selectedProduct = tempCart.find(item => item.id === id)

       const index = tempCart.indexOf(selectedProduct)
       const product = tempCart[index]
let tempProducts = [...this.state.products]
       const index = tempProducts.indexOf(this.getItem(id))
       const product = tempProducts[index]


P.s. в getItem ведëтся поиск по products.
источник

t

th.witness in pro.js
"Не опять, а снова!"
источник

p

persona x grata in pro.js
Красава
источник