Y
Hacker News
new
|
ask
|
show
|
jobs
by
teniutza
2651 days ago
Sometimes I need to create the props at a different level/location and not directly on the component. The interface for the (class component) props is then very useful.
1 comments
littlecranky67
2651 days ago
This is no different when using Hooks. You specify the type of props as the type of the first argument in the functional component:
function MyComponent(props: IMyComponentProps) { ... }
Where the type definition of IMyComponentProps resides doesn't matter, you can import it from anywhere.
link
teniutza
2650 days ago
I was simply pointing out that explicitly defining an interface is not necessarily a downside.
link