0

I want to use map method with an array to define initial value of a state.

My thoughts:

import data from "./data.js"

const [state, setState] = useState([

    data.map((item)=>
        {
            value: item.value
        }
    )

])

But it's not working. Is there a good practice about this case?

yusufcode
  • 391
  • 5
  • 19

0 Answers0