F
F
faleaksey2019-01-15 13:02:54
React
faleaksey, 2019-01-15 13:02:54

How to implement the "Save" component?

Hello! on air bnb, on the product cards there is a component "Save to favorites (liked)" 5c3daf332e63b779601619.jpeg
How to implement it? as I understand it, we have the main state where the state of the entire application is stored + an array with products (product cards) ... when I click on like, do I change false to true on the product card itself or just the like component? is the like button a separate component?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2019-01-15
@faleaksey

the option "when I click on like, I change false to true of the product card itself" - OK (meaning, you change one of the properties in the object with data about this ad, for example: isFavourite: true)
In a real application, the request flies to the server, which the client such-and-such noted such-and-such an object in favorites.

A
Alexey Ukolov, 2019-01-15
@alexey-m-ukolov

Separate. Or not separate - as you wish. I prefer maximum decomposition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question