Add class to default value component
See original GitHub issueHello recently i been working with multi select and needed to highlight the value that had been clicked. I accomplished it by using default Value component as valueComponent and adding class to it. But only way to add class it to mutate props.value. Is there better way to add class to default value component?
Here my code.
import Value from 'react-select/src/Value';
ValueComponent(props){
if (props.value.value === this.props.highlighted){
props.value.className = 'Select-value-highlighted';
}
return (<Value {...props}/>);
}
<Select
...
valueComponent = {this.ValueComponent}
/>
One other way is to wrap component with div that have class, but this div will be redundant and css will look not so clean.
Also will it be bette if you expose Value directly, so it can be imported like following? `import {Value} from ‘react-select’;``
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
setting default value for react class component state in typescript
There is no way to set a "default value" directly on an interface, you have to do it in the initialization of the...
Read more >DefaultValueAttribute Class (System.ComponentModel)
You can create a DefaultValueAttribute with any value. A member's default value is typically its initial value. A visual designer can use the...
Read more >A complete guide to React default props - LogRocket Blog
Cover three ways to implement default props in React and provide default values for props that are not required by the component.
Read more >Classes - JavaScript - MDN Web Docs
As seen above, the fields can be declared with or without a default value. See public class fields for more information. Private field ......
Read more >Component field default value | Acquia Cohesion Docs
You can set a default value on your component form element, this is optional. The default value will be used when the Component...
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 FreeTop 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
Top GitHub Comments
@dspoonia7 No I didn’t. I end up with modifying
props.value.className
as mentioned earlier.Hello -
In an effort to sustain the
react-select
project going forward, we’re closing old issues / pull requests.We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.
If you feel this issue / pull request is still relevant and you’d like us to review it, please leave a comment and we’ll do our best to get back to you.