M
M
MarEeeeeee2020-12-19 15:37:41
React
MarEeeeeee, 2020-12-19 15:37:41

How to get data from div field in React?

Hello everyone, there is a component, you need to click on the line with data (window_items) to get data from all internal blocks in order to work with them later, for example, delete

function FirstWindowItems({item}) {
    function handleClick(element){
        // e.preventDefault();
        console.log(element);
      }




    return(
        <div className = "window__items" onClick = {handleClick(element)}>
            {/* <div className = "window__item window__name">{item.id}</div> */}
            <div className = "window__item window__name">{item.FIO}</div>
            <div className = "window__item window__name">{item.position}</div>
            <div className = "window__item window__name">{item.birthDay}</div>
            <div className = "window__item window__name">
                {
                    item.sex ?
                        "М" : "Ж"                    
                }            
            </div>
            <div className = "window__item window__name">{
            item.fired ?
                "Уволен":"Работает"
            }
            </div>            
        </div>
    )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-12-19
@MarEeeeeee

A counter question: how did the data you need get to where you are going to "receive" it from? You don't need to do anything, everything is already there - work inside the handleClick with the item object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question