rad-ui / ui

Rad UI is an open-source, headless UI component library for building modern, fast, performant, accessible React applications
http://rad-ui.com
MIT License
11 stars 13 forks source link

Potential misuse of extending for optional props #171

Open CCleanerShot opened 8 months ago

CCleanerShot commented 8 months ago

For several components, there are allowed optional properties to be passed into them, which are undeclared by the component's props interface themselves.

Example:

interface Props: { props?: Record<string, any>[] }
const Test = ({...props}: Props) => {

return <div {...props}></div>
} 

I am not sure if the use of Record<string, any>[] is poor, as a property key value may potentially be a number or such.

Close this issue upon clarification

kotAPI commented 8 months ago

Let's keep this open and settle on how we should approach this - allowing ...props for component is important as the devs might want to add some additional properties to the html tags

for example - adding unique ids for usage in end to end tests - without this, it could be very difficult for the consumers of the components to interact with our library in automation tests - one of the many reasons why this is important

CCleanerShot commented 7 months ago

Upon further research, I think this is the sadly the best solution. Feel free to re-open if you find something. This strangely accounts React saying that they will deprecate it, despite being the only solid way of doing this.

The video that was mentioned in discord that provided an alternative doesn't even work.

CCleanerShot commented 7 months ago

omg i posted it in the wrong issue