How to specify the structure of state and to update it with different choice?

I have filter components -> priceFilter, colorFilter

Each of them has different content. I need to ask what value is selected and display them at the bottom. One of the components multiple selection, single selection another.

I chose this structure state:
{
{
 id: 'refinementColor', // id of the filter
 value: [] // is single selection then ""
}
}


Well, each time you select add to state key - value:
{
{
 id: 'refinementColor', // id of the filter
 value: [] // is single selection then ""
}
}


Click on the price:
{
{
 id: 'refinementColor',
 value: []
},
{
 id: "price",
 value: "900$ - 200$"
}
}


CodeSandbox - https://codesandbox.io/s/stoic-bhaskara-o4ntp?file...

Whether I chose the structure and how do I correctly update values?
April 19th 20 at 12:23
1 answer
April 19th 20 at 12:25
Solution
@helen
Ask for apologies, but:
But how to set id??

{
 id: 'refinementColor',
 value: []
 },


To me it's a must, because then I'm going to do selectedValues[id] - donnell63 commented on April 19th 20 at 12:28
@donnell63, if you think you have well explained what you have... No, it's not. - helen commented on April 19th 20 at 12:31

Find more questions by tags ReactJavaScript