by ng12 · 7y ago · 0 comments
The most important thing is it makes it difficult to build the same tooling that other frameworks have. For example, in React you can either define your props as a TypeScript/Flow interfaces or use the `prop-types` library. This gives you an easy way to automatically validate props outside of the context of component instantiation. For example, you can do:
import MyComponent, {MyComponentProps} from "./MyComponent"
const props: MyComponentProps = {...}
Or you can do things like composing props (using prop-types here): import {propTypes} from "./MyComponent"
import {propTypes as otherPropTypes} from "./MyOtherComponent"
const MyNewComponent = () => {...}
MyNewComponent.propTypes = {...propTypes, ...otherPropTypes}
All this is possible since props is just a single object that is baked into the React API. In my own Svelte project I've been toying with the idea of only having a single prop called `props` although I'm sure this affects Svelte's rendering performance.