L
L
lookingfor22020-09-29 12:23:04
React
lookingfor2, 2020-09-29 12:23:04

How to select the first element from an object on first load?

There is a header, when clicked, a list of products appears

<h3 onClick={() => onShowSelectList(!showSelectList)}
       className={props.className + "-select-title"}>
       {selectedValue ? selectedValue : props.title}
</h3>

In the value, we indicate that if the product is not selected, we take props.title from the prop, how to specify when loading the page that if the product is not selected, we select the first position from the list. The list object is stored in props.data.

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