[v2.0.0-beta.2] Custom ValueContainer doesn't work without rendering "children"
See original GitHub issueI’m trying to use the ValueContainer option to render the selected option differently. Seems I cannot do that and still let the selected option (ValueContainer) be clickable and open the menu without also rendering the children prop. However, in rendering the children prop, I’m basically rendering the selected option twice. Clicking the arrow still works though.
Basically, this works fine (example from docs):
const ValueContainer = ({children, ...props}) => (
<components.ValueContainer {...props}>{children}</components.ValueContainer>
);
This does not work:
const ValueContainer = ({children, ...props}) => {
if (!props.hasValue) {
return <components.ValueContainer {...props}>{children}</components.ValueContainer>;
}
const value = props.getValue()[0];
return (
<components.ValueContainer {...props}>
<NodeItem node={value} />
</components.ValueContainer>
);
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:35
- Comments:29
Top Results From Across the Web
[v2.0.0-beta.2] Custom ValueContainer doesn't work without ...
[v2.0.0-beta.2] Custom ValueContainer doesn't work without rendering "children"
Read more >React-Select losing focus for custom component ...
ValueContainer has two objects when there's no value selected: ... out that you should put the custom value container outside the render
Read more >react-select-fixed-v2/HISTORY.md
This is part of the work to normalize the behaviour circa custom components. ... 319, * Fixed inline-block rendering for arrowRenderer without autosize, ......
Read more >React-select custom ValueContainer
CodeSandbox is an online editor tailored for web applications.
Read more >https://raw.githubusercontent.com/Kashkovsky/react...
This is part of the work to normalize the behaviour circa custom components. ... Fixed inline-block rendering for arrowRenderer without autosize, ...
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
You could filter out the input from
children
so you can still keep standard functionality:We were also facing this problem for a while. And below is the working code for us.
inputId
prop to<Select>
component like below: