question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextInput onBlur callback as option?

See original GitHub issue
  • tcomb-form-native v0.4.0
  • react-native v0.21.0

For the TextInput field type you list among other standard options onBlur, onEndEditing, onFocus and onSubmitEditing. Can you give an example of how a callback would be indicated for these options?

var options = {
  fields: {
    textField: {
      onFocus: [ How do I code the callback here? ]
    }
  }
};

I find this library to be immensely helpful. Thanks for all of your work!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
alvarombcommented, Mar 25, 2016

Basically, you can do this @flyingace

let options = {
  fields: {
    textField: {
      onFocus: () => { console.log('Your code here'); },
      // or
      onFocus: this._myOnFocusFunction.bind(this),
    },
  },
}

_myOnFocusFunction () {
  // Your code here
}
1reaction
sirwoetangcommented, Jul 4, 2016

Is there any way to scroll the focussed text component to the top of the page? I believe this should be a natural next step for most forms.

Something like this?

  _myOnFocusFunction (componentName) {
    if (componentName) {
      var component = this.refs.form1.getComponent(componentName)
      this.refs._requestScrollView.scrollTo({y: component.height})
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between onEndEditing and onBlur? - Stack Overflow
Callback that is called when the text input is blurred. Is there a scenario where it can't be solved just with onBlur ,...
Read more >
TextInput - React Native
Use it with multiline set to true to be able to fill the lines. Type. number. onBlur ​. Callback that is called when...
Read more >
TextInput · React Native
Two methods exposed via the native element are .focus() and .blur() that will focus or blur the TextInput programmatically.
Read more >
react-hook-form controlled input onblur doesn't work - You.com
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
onblur Event - W3Schools
The onblur event occurs when an element loses focus. The onblur event is often used on input fields. The onblur event is often...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found