question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird typings for onChange badly needs a refactor.

See original GitHub issue

These 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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ebonowcommented, Oct 14, 2021

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 or Number instead of an Object.

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.

1reaction
Methuselah96commented, Aug 9, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found