0

Есть файл с компонентом file1.tsx

    return (
    <>
  <SafeAreaView style={styles.droidSafeArea}/>
  <SafeAreaView style={styles.container}>
  <CustomHeader title='Сканер' navigation={this.props.navigation} />
    <View style={{ flex: 1 }}>
      <BarCodeScanner
        onBarCodeScanned={this.onBarCodeRead}
        style={StyleSheet.absoluteFill}
      />
      {this.renderMessage()}
    </View>
  </SafeAreaView>
  </>
);

Как мне передать {this.renderMessage()} в другой файл с компонентом?

    render(){
    return(
        <View>
            {/* <Text {...this.props}>Helli, {this.props.lol}</Text> */}
    <Text>{Функция из file1.tsx}</Text>
        </View>
    )
}

1 ответ 1

0
class App {
 renderMessage = () => <View />

 render() {
  return (
   <File1>
   {this.renderMessage()}
   </File1>
  );
 }
}

class File1 {

 render() {
  return (
   <View>
    {this.props.children}
   </View>
  );
 }
}
1
  • пожалуйста, постарайтесь оставлять чуть более развёрнутые ответы. дополнить ответ можно, нажав править 23 июн 2020 в 12:23

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.