react-select default value not working/selecting

  Kiến thức lập trình

I use react-select and want to use defaultValue but its not working.

here is my code:

     <Select className="select-type stp" defaultValue={brandModel.map((el => ({
                value: el,
                label: el
                })))[brandModel.findIndex(el => el === car?.model)]} options={brandModel.map((el => ({
                  value: el,
                  label: el
                })))} />

if I console.log this

brandModel.map((el => ({
                value: el,
                label: el
                })))[brandModel.findIndex(el => el === car?.model)

I get this:

{label: '116', value: '116'}

so the result are correct but why its not showing it

New contributor

cenk kandemir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT