fix(typings): unable to set many typical html element props
See original GitHub issueI was running in to problems trying to set the id
attribute for Segment
. Currently the typings don’t allow this in TSX, even if it would be perfectly ok in JSX. The same is true for a number of other standard html attributes and Semantic-UI-React-Components.
One option would be to change
interface SegmentProps {
to
interface SegmentProps extends React.HTMLProps<HTMLElement> {
giving the ability to set a huge amount of additional attributes, including id
. This however floods the intellisense with attributes that are probably unneeded 95% of the time.
Another option would be to add an index type:
interface SegmentProps {
...
[key: string]: any;
}
which would then allow any property to be set without flooding intellisense.
Any thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Extending HTML elements in React and TypeScript while ...
I always use React.ComponentsProps<"button"> the generic input can be anything from a react component to a string such as "div". There are also ......
Read more >Separate HTML attributes from styling props #439 - GitHub
I am trying to style a 3rd party "masked" input. The styles are applied correctly, however, there are props I pass into the...
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
Wrapping/Mirroring a HTML Element. Usecase: you want to make a <Button> that takes all the normal props of <button> and does extra stuff ......
Read more >Build strongly typed polymorphic components with React and ...
Learn how to build strongly typed polymorphic React components with TypeScript, using familiar Chakra UI and MUI component props as guides.
Read more >How To Customize React Components with Props
In this tutorial, you'll create custom components by passing props to your component. Props are arguments that you provide to a JSX element....
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
🎉 all praise be to you @layershifter, completely amazing work!
@dstpierre awesome! I’d prefer we do only a few at a time. It is easier to review and manage conflicts that way. Also, anytime there is a list of items todo like this, there always seems to be other small bug fixes and updates that are necessary along the way. Keeping the PRs small keeps the changes manageable, whereas, grouping them tends to lead to a massive PR that has a very hard time getting merged.