Closed TimoteoGambella closed 1 year ago
Just pass one or more options to the value prop as array:
values={[options[0]]}
On Thu, Apr 27, 2023, 12:32 AM TimoteoGambella @.***> wrote:
Can i put a default value when the component render?
— Reply to this email directly, view it on GitHub https://github.com/sanusart/react-dropdown-select/issues/277, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACBLRVXVVAVRRTX3PM7EQ3XDGH6HANCNFSM6AAAAAAXM75TSE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@sanusart I want to know the same thing, I tried to add an array to the value, but it shows (54 of 5 selected), I have the contentRenderer.
I have the following array:
[{"title": "Title1", "value": "Value1"},{"title": "Title2", "value": "Value2"}]
Can you reproduce in code sandbox?
@sanusart, hereby the codesandbox: https://codesandbox.io/p/sandbox/dropdown-test-z3fgqq?file=%2Fsrc%2FApp.js%3A85%2C25
As you can see the dropdown shows: 35 of 5 selected.
The const rooms holds all the values that the dropdown should show. The const dataFromDb is the data from the DB (hence the name). The dropdown should only show the value Room1 to be selected. But it should way more than it has.
Hey, change the values prop to be: values={[...dataFromDb]}
Not sure where the JSON.stringify idea came from.
On Mon, Aug 5, 2024 at 10:45 PM udarts @.***> wrote:
@sanusart https://github.com/sanusart, hereby the codesandbox: https://codesandbox.io/p/sandbox/dropdown-test-z3fgqq?file=%2Fsrc%2FApp.js%3A85%2C25
As you can see the dropdown shows: 35 of 5 selected.
The const rooms holds all the values that the dropdown should show. The const dataFromDb is the data from the DB (hence the name). The dropdown should only show the value Room1 to be selected. But it should way more than it has.
— Reply to this email directly, view it on GitHub https://github.com/sanusart/react-dropdown-select/issues/277#issuecomment-2269789129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACBLRVGSBRYSVMRQPZD3ZDZP7I53AVCNFSM6AAAAABL6EVZPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZG44DSMJSHE . You are receiving this because you were mentioned.Message ID: @.***>
Can i put a default value when the component render?