React.Component
에서 상속받은 BaseComponent가 있습니다. 앱의 다른 모든 구성 요소는 BaseComponent
에서 상속됩니다. 나는 BaseComponent
을 입력해야합니다. 그로부터 상속받은 다른 구성 요소는 Flow에 의해 React 구성 요소로 처리됩니다. 현재 내가 가지고있는 것 :흐름 유형 정보를 잃지 않고 사용자 정의 반응 구성 요소로부터 상속을 얻으려면 어떻게해야합니까?
class BaseComponent<P, S> extends React.Component<$Shape<P>, P, S> {
...
}
class OtherComponent extends BaseComponent {
props: {};
state: {}:
...
}
여기에 working example입니다. 흐름은 OtherComponent
에서 소품, 주 등을 올바르게 점검합니다. BaseComponent에서
S: This type is incompatible with 'undefined. Did you forget to declare S?
P: This type is incompatible with 'undefined. Did you forget to declare P?
Did you forget to declare some incompatible instantiation of
S?: This type is incompatible with 'some incompatible instantiation of
S'
오류 메시지를 이해하는 데 어려움을 겪고 있습니다. 어떤 도움이라도 대단히 감사하겠습니다.
'BaseComponent'를'P'와'S'로 매개 변수화했습니다. 'BaseComponent'를 확장 할 때 값을 제공해야합니다. https://flowtype.org/docs/classes.html#polymorphic-classes를 참조하십시오. –
@FelixKling 감사합니다! 형식 값을 전달하고 있습니다. 문제를 설명하는 flowtype.org/try 예제를 추가했습니다. 명확히하기 위해, 내가하고있는 것은 흐름이'OtherComponent'를 올바르게 입력하도록하지만,'BaseComponent'에 대한 에러를 보여줍니다. 작업 예제를 참조하십시오. – alden