Home > Software engineering >  How to set default value in Select Component?
How to set default value in Select Component?

Time:10-29

On React Carbon Select component I want to have a default selected option, which can be changed, of course.
In general my goal is to implement edit functionality.
It means user should be able to change already selected option.
I tried with adding the value property directly in Select like value={defaultSelected} or defaultValue={defaultSelected} but it didn't work.

Code example.

import React, { useState } from 'react';
import { Select, SelectItem } from '@carbon/react';

const options = [
  {
    value: 'apple',
    text: 'Apple            
  • Related