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

131
Views
Después de envolver la función de flecha, ¿por qué la función se ejecuta inmediatamente?

Estoy haciendo una aplicación con reaccionar nativo. Si no hay respuesta táctil en una pantalla actual, quiero una acción que avance automáticamente a la siguiente pantalla después de 5 segundos.

Si se presiona un botón o se ingresa texto de entrada, estoy pensando en borrar setTimeout y contar 5 segundos nuevamente. Así que envolví las funciones para poner onPress y onChange que tengo en la pantalla. Sin embargo, funciona como si se hubiera presionado el botón. ¿Cómo debo envolverlo?... Te agradecería que me lo hicieras saber.

 //ReceiptScreen ... componentWillUnmount() { this._isMounted = false; clearTimeout(this.nextScreenTimer); } handleSendPress = () => { if (isValidEmail(this.state.email)) { this.props.sendEmailReceipt(this.state.email, this.props.order); } else { Alert.alert( null, [ { text: 'close', onPress: () => null, }, ], {cancelable: true}, ); } }; handleScreenTimeout = func => { console.log('what', func); clearTimeout(this.nextScreenTimer); this.nextScreenTimer = setTimeout(() => { this.handlePressClose(); }, 5000); func(); }; componentDidMount() { this.nextScreenTimer = setTimeout(() => { this.handlePressClose(); }, 5000); } .... render() { .... <InputButton placeholder={'example@gmail.com'} value={this.state.email} onChangeText={text => this.setState({email: text})} loading={this.props.isEmailReceiptFetching} onPress={this.handleScreenTimeout(this.handleSendPress)} /> }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe cambiar el siguiente controlador onPress

 onPress={this.handleScreenTimeout(this.handleSendPress)}

ser una función que llame a su función dentro de ella como se muestra a continuación

 onPress={() => this.handleScreenTimeout(this.handleSendPress)}
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!