Weird typings for onChange badly needs a refactor.
See original GitHub issueThese types are silly:
const [ selectedValues, setSelectedValues ] = useState<OptionsType<OptionType>>([])
const handleChange = (values: OptionsType<OptionType>, actionMeta: ActionMeta<OptionType>) => {
// do something
}
Not only are these types unintuitive in of themselves, but they are also not well explained neither in the docs nor elsewhere online. Problem solving these types has costed me a huge amount of time. As much as I would love to replace these types with “any”, I’m working with a strict linter that doesn’t allow such things. I seriously look forward to the day when I can just dip in-and-out of a visual editor like Webflow to do UI, but since visual editors don’t yet integrate with complex code bases, I’m stuck dealing with silly types likes these.
Please consider making it a priority to both refactor these ugly types and to update the docs to make it easier to apply them.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Strange behavior with onChange in overridden Composer for ...
Composer remains intact and onChange sends back event information to be able to fire off that the user is typing.
Read more >There's a lot of bad advice being tossed around in this thread ...
I don't think subcontractors build bad systems on purpose, but rather they build systems to bad requirements. A lot of times you have...
Read more >How to perform debounce? - Stack Overflow
In 2018, working with callbacks (Lodash/Underscore) feels bad and error-prone to me. ... render: function () { return ( <input type="search" onChange={this.
Read more >formik onchange not working
Onchange modifies the value (needed for required validation, hence the setTouched of location.value) One solution from the author https .
Read more >Practical Ways to Write Better JavaScript - Stack Overflow Blog
Typescript types make refactoring larger applications possible. Refactoring a large JS application can be a true nightmare. Most of the pain of ...
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
This was a complete refactoring of Flow to TypeScript. We are happy to consider any updates to the types, but these conversations would likely be a better fit for the Discussions area as would any topic regarding a change from value representing a
String
orNumber
instead of anObject
.Again this rewrite was based on the intention of creating compatible code. The next major version would likely be a bit more opinionated with breaking changes (like the one mentioned above abut changing the type of the value), so it’s one that we would happily address if it were a popular topic in the Discussions area and made sense to do so.
Suggestions are far more helpful than judgements.
How would you suggest we refactor the types? Feel free to suggest better types and/or open a PR with the changes.
We’re working on improving the documentation website, so hopefully once that’s done there will be opportunity to add some documentation for using the types. Feel free to create a PR for adding that documentation now as well though.