0
내가 (React typeReference에서) 내 구성 요소에 flowtype 주석의 스타일을 추가하기 위해 노력하고있어의 형태JSX에 유형 약어 실수를 추가하기 JSX 태그
class Foo extends React.Component<{}> {}
function Bar(props: {}) {}
(<Foo />: React.Element<typeof Foo>); // OK
(<Bar />: React.Element<typeof Bar>); // OK
(<Foo />: React.Element<typeof Bar>); // Error: Foo is not Bar
내 시도 :
import React, { Component } from 'react'
import type { Node, Element } from 'react'
class AlertModalComponent extends Component<iAlertModal, State> {
render(): Node {
return (
<View style={alertModalStyle.container}>
(<PresentationalModal
style={{ backgroundColor: 'transparent' }}
isOpen={this.props.isOpen}
title={this.props.title}
message={this.props.message}
updateAlertModalHeight={this.props.updateAlertModalHeight}
viewHeight={this.props.viewHeight}
hasYesNo={this.props.hasYesNo}
yesClicked={this.props.yesClicked}
updateAlertModalIsOpen={this.props.updateAlertModalIsOpen}
/>: Element<typeof PresentationalModal>)
</View>
)
}
}
// $FlowFixMe
export default connect(mapStateToProps, mapDispatchToProps)(AlertModalComponent)
AlertModalComponent.contextTypes = {
store: PropTypes.object
}
const PresentationalModal: Function = ({
isOpen,
title,...
}: AlertModal) => {
console.log('presentational modal yes no')
return (
<Modal style={alertModalStyle.modal} isVisible={isOpen}>
...
오류 :
가Expected corresponding JSX closing tag for
<typeof>
그것은 <typeof>
생각은 jsx 태그입니다. 이 오류에 대한 해결책은 무엇입니까?
흠 좋습니다. 비록 타입 typotference에서 내 예제에서 JSX에 유형 주석이 추가되지 않습니까? – BeniaminoBaggins
차이점은 맨 위의 예는 입력되는 전체 jsx 값입니다. 반면 작동하지 않는 jsx 값은 jsx 표현식의 중간에 있습니다. – TLadd