Strange behaviour with select and default value
See original GitHub issueSteps to reproduce
I’ve created a new rails app 5.1 and add react-rails 2.4.3:
rails new ciccio
cd ciccio
echo "gem 'react-rails'" >> Gemfile
bundle
rails g react:install
rails g scaffold post title body:text
rails db:migrate
I’ve create a simple React component Hello.jsx
class Hello extends React.Component {
render() {
return(
<div>
<select defaultValue={1}>
<option value={1}>Select this to set value to {1}</option>
<option value={2}>Select this to set value to {2}</option>
</select>
</div>
)
}
}
And I render this component on app/views/posts/index.html.erb
<%= react_component('Hello', {}, {prerender: true}) %>
Expected behavior
When I visit the page http://localhost:3000/posts I should see the select and nothing on console.log
Actual behavior
In console.log I get Warning: Text content did not match. Server: "Select this to set value to 1" Client: "Select this to set value to "
System configuration
Sprockets version: 3.7.1 React-Rails version: 2.4.3 Rails version: 5.1 Ruby version: 2.4.2
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Strange behaviour in Select defaultValue · Issue #3483 - GitHub
Hi , i am trying solve a problem, which is related to defaultValue's strange behaviour. I have 2 select components which are handled...
Read more >Oracle showing strange behaviour while populating default ...
1. Default values are only used when a column is not referenced in an insert statement. · 2. If the column is referenced,...
Read more >Solved: Dropdown default value inconsistent
I'm attempting to set the 'default' value from a. ... This odd behaviour is pretty reliable in its bizzare way. Why would some...
Read more >Strange behavior of select element when choosing options
Normally when you click on a select element, the option you have selected is highlighted by default and as you scroll to other...
Read more >Very strange behaviour of Form::select() - Laracasts
This is two cases with different behaviour. In the first: select box will always have a default value. Why Form::select() ignores default value...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pioz If you don’t have React Dev Tools installed, first step in troubleshooting this is to install them and inspect actual props passed to the select tag.
No updates on this for a long time. Closing this one.