Replies: 1 comment 3 replies
-
Greetings @dreamwasp , The DummyInput only exists for the purpose of determining is the Select is focused or blurred (which triggers the styling or hiding/showing menu). It has no correlation to any selected value. Additionally, the Input component itself will clear will its value by default unless that behavior is overridden. What you might be aiming for is not the DummyInput, but rather the generated hidden field which has no official component name but can be seen here: react-select/packages/react-select/src/Select.tsx Line 1884 in e6ff154 This renders only if a name has been provided for the Select so that the form can use this value when submitting a form natively. You should be able to access this onMount using a hook and querying for the hidden input field with the same provided name you gave to your select. Of course you can adjust the query selector to better fit your needs should you have multiple instances. const RecurlySelect = ({ recurly, name, ...props }) => {
useEffect(() => {
const query = `input[name="${name}"]`;
const input = document.querySelector(query);
input.setAttribute("data-recurly", recurly);
}, [name, recurly]);
return <Select {...props} name={name} />;
}; Please let me know if this helps or if I am missing something in this implementation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've run into a situation where I would like to replace the DummyInput rendered when isSearchable is false, as is possible with other components of React-Select.
- What's your use case?
I need to spread custom props directly onto the HTML
input
, which I also need to maintain its value in the DOM when an element is selected. I am using this with React-Recurly which requires both of these things. For instance:- What interface do you have in mind?
I would like to be able to replace DummyInput through the
components
prop.- Can you point to similar functionality with any existing libraries or components?
I have a rough draft of when I am proposing pushed on this branch, I think it makes sense to have DummyInput be replaceable as Input itself is replaceable.
Beta Was this translation helpful? Give feedback.
All reactions