gcanti / tcomb-form

Forms library for react
https://gcanti.github.io/tcomb-form
MIT License
1.16k stars 136 forks source link

onChange attr does not work #355

Closed msaron closed 7 years ago

msaron commented 7 years ago

tcomb-form version 0.9.10 react version 15.3.0

I am trying to use the attrs for a select field as follows:

    const options = {
      fields: {
        _limit: {
          label: 'Rows',
          nullOption: false,
          attrs: {
            onBlur: () => console.log('onBlur'),
            onChange: () => console.log('onChange')
          }
        }
      }
    };

The onBlur works but the onChange does not work. Any idea as to why that is so?

gcanti commented 7 years ago

onChange is used by tcomb-form in order to detect changes. You can define an onChange handler for the Form component though https://github.com/gcanti/tcomb-form/blob/master/GUIDE.md#adding-a-default-value-and-listening-to-changes