子コンポーネントはパラメーター付きの関数を受け入れ、パラメーターを親コンポーネント関数に渡します
親コンポーネント:
<IDTypeDialogView hide = {()=> {this.hideCoverLayer()}} type = {(type)=> {this.setStateCredentials_type(type)}} />
親コンポーネント機能:
setStateCredentials_type(type){//带参 this.setState({credentials_type:type}); }
hideCoverLayer(){//無参 this.coverLayer.hide(); }
カスタムサブコンポーネント:props。メソッド名。Bind(null、 'parameter')
const IDTypeDialogView = props =>( <View style = { {height:138、width:DEVICE_WIDTH、backgroundColor: 'white'}}> <View style = { { flex:1、 flexDirection: 'row'、 height:45、 paddingLeft :15、 paddingRight:15、 alignItems: 'center'、 justifyContent: 'space-between'、 }}> <Text onPress = {props.hide}>キャンセル</ Text> <Text style = { {color: '#3d61ff '}} onPress = {props.hide}> OK </ Text> </ View> <View> <テキストスタイル= { {height:45、alignSelf: 'center'}} onPress = {props.type.bind(null、 'Passport')}>パスポート</ Text> <Text style = { {height:45、alignSelf: 'center'} } onPress = {props.type.bind(null、 'ID Card')}> IDカード</ Text> </ View> </ View> ); デフォルトのIDTypeDialogViewをエクスポートします。