S
S
sinevik2018-02-26 19:24:50
React
sinevik, 2018-02-26 19:24:50

How can I make defaultValue work when state changes?

<select onChange={this.props.changesource}>
          <option defaultValue>Выбрать источник</option>
      				         <option value="abc-news">Abc-News</option>
           <option value="cbs-news">CBS News</option>
           <option value="daily-mail">Daily Mail</option>
           <option value="national-geographic">National Geographic</option>
           <option value="newsweek">Newsweek</option>
</select>

When the user selects a news source, the state of the parent component changes. I need that every time the state changes, the default value is set

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-02-26
@sinevik

There is no defaultValue for select.
If you need to make some value in select selected by default, then just specify value at the <select>
documentation tag

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question