Rewrite / 1.0
See original GitHub issueI’m midway through a massive rewrite of this library and wanted to open an issue so it’s more visible. There will be several breaking changes to the API, all for the better.
WIP is visible on the rebuild
branch.
Aside from how we’re bundling lib
and dist
files (which won’t change for now), it basically addresses all the things that @brianreavis raised in #227.
I’ve been trying to split Select up into more granular components as suggested by @bruderstein in #396, but it’s not obvious how to do this while also cleaning everything up and preserving a simple API so that can probably be the focus of another major version down the track.
The big improvements include:
- Everything is simpler (I’m nearly done and the source code is only 60% of the size of the last version)
- No more timeouts or weird handlers, the restructuring has let me make everything more straight-forward
- The options array is no longer preprocessed into state, just retrieved from props
- The values array is now initialised in the Options array during render, and not stored in state, which along with the change to options makes the component more reliable and fixes issues with props not updating correctly
- The component no longer stores its own value in state (ever) - it needs to be passed as a prop and handled with
onChange
. - Complex values are now enabled by default (so you’re passed the option object, not its value); you can enable the legacy mode with a prop
- The Value and Option components have been cleaned up as well for consistency
- The hidden
<input>
field is now optional and the component is better suited to use in a rich React.js app than it was - You can disable options filtering to do the filtering externally with
onInputChange
- Accents on characters can now be ignored
The other major change is that the whole async options loading piece has been split out into its own Select.Async
component, which wraps Select
and passes most props through. This dramatically simplifies the select component itself, and plays nicely with the new “options and value are just props” changes. Props that were related to asyncOptions
have also been moved to the new component.
Aside from the details of what’s been changed, it just feels better to use, more solid. I don’t have benchmarks to back this up, but it should be much faster too (and easier to optimise in subsequent versions)
Issue Analytics
- State:
- Created 8 years ago
- Reactions:97
- Comments:39 (9 by maintainers)
Top GitHub Comments
@JedWatson Where are you guys with a stable 1.0.0 release? I would be more than willing to help. I’ve been using the old stable for a while now and would love to upgrade @nozzle to 1.0.0
1.0.0 is out 🎉