You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is very flexible, but it brings difficulties to type inference.
Specifically, how can parent component know it has a onAbc props? What is the type of evt.detail?
The text was updated successfully, but these errors were encountered:
You can resolve this issue like you would normally do in, for example, react on typescript - declaring an Interface and relying on it at parent's component.
@volodymyrlut You are right, we can write an interface to describe the onAbc, then parent component can rely on it.
However, in React, child component can also rely on it:
interfaceChildProps{onAbc: (n: number)=>string;}classChildextendsReact.Component<ChildProps>{doSomething(){// Here ts know that onAbc should pass an argument with number typethis.props.onAbc(200);}}
interfaceChildProps{onAbc: (n: number)=>string;}classChildextendsOmi.WeElement<ChildProps>{doSomething(){// It's hard to know that if the first argument is string 'abc', then the second argument needs to be a numberthis.fire('abc',200);}}
Omi use this syntax to create a custom event:
This is very flexible, but it brings difficulties to type inference.
Specifically, how can parent component know it has a
onAbc
props? What is the type ofevt.detail
?The text was updated successfully, but these errors were encountered: