Extract option, value and single value to components and allow getting customized ones #328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I recently bumped into case where we needed to make some customization of options and values render. I checked the options that are provided (similar to select2 formatResult) and somehow probably would deal with it this way.
However, I am pretty sure that better solution would be to wrap all these parts that often demands customization (like option/value renders) into components that can be provided via props by the user. Of course, they would need to handle proper API that should be documented.
This way, eventually react-select would become free of tens of customization props (classes, formaters, etc.). All of this could be handled directly by the user providing customized components based on default ones and handle basically every edge customization case.
What do you think? I prepared a fork that meets my requirements and is ready to merge, despite the lack of additional documentation that I can add. There is also an additional example showing how it can be useful with integrating 3rd-party components (in this example its react-gravatar.
I would love to hear your opinion.