Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Reaccionar nativo navegar a otra pantalla

Estoy tratando de redirigir a CallScreen, pero no se llama a la función redirigir (). Mi código está en https://pastebin.com/FKLfGxhR , se supone que se llama a la función

 options={{ 'Choose From Library': () => { this.redirect(); }, }}

aquí.

La función está en la clase, y es

 redirect = () => { this.props.navigation.navigate('CallScreen') console.log('test')

}

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

renderActions debe ser un método de la clase. Al convertirlo en un método, también debe usar this.renderActions en lugar de renderActions

 class ChatScreen extends React.Component { renderActions = (props) => { return <Actions {...props} containerStyle={{ width: 44, height: 44, alignItems: 'center', justifyContent: 'center', marginLeft: 4, marginRight: 4, marginBottom: 0, }} icon={() => ( <Image style={{ width: 32, height: 32 }} source={{ uri: 'https://placeimg.com/32/32/any', }} /> )} options={{ 'Choose From Library': () => { this.redirect(); }, }} optionTintColor="#222B45" /> }; redirect = () => { this.props.navigation.navigate('CallScreen') console.log('test') } state = { messages: [], }; get user() { const { name, id, avatar } = this.props.route.params; return { name: name, _id: id, avatar: avatar, }; } componentDidMount() { FirebaseStorage.shared.on(message => this.setState(previousState => ({ messages: GiftedChat.append(previousState.messages, message), })) ); } componentWillUnmount() { FirebaseStorage.shared.off(); } render() { return <SafeAreaView style={{flex: 1}}> <GiftedChat messages={this.state.messages} onSend={FirebaseStorage.shared.send} user={this.user} alwaysShowSend showUserAvatar isAnimated showAvatarForEveryMessage renderBubble={this.renderBubble} renderMessageImage={() => this.showImage} renderUsernameOnMessage isTyping renderActions={this.renderActions} /> </SafeAreaView> } }
about 4 years ago · Juan Pablo Isaza Report

0

renderActions debe vivir dentro Component antes de llamar a this .

 class ChatScreen extends React.Component { //..your stuff const renderActions = (props) => { return <Actions ...props options={{ 'Choose From Library': () => { //It is safe to call this.XXX from here this.redirect(); }, }} /> }; render() { return <SafeAreaView style={{flex: 1}}> <GiftedChat messages={this.state.messages} onSend={FirebaseStorage.shared.send} user={this.user} alwaysShowSend showUserAvatar isAnimated showAvatarForEveryMessage renderBubble={this.renderBubble} renderMessageImage={() => this.showImage} renderUsernameOnMessage isTyping renderActions={renderActions} /> </SafeAreaView> } redirect = () => { this.props.navigation.navigate('CallScreen') console.log('test') } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!