reactjs - redux-form-material-ui using getRenderedComponent() throws always an error -


i'm basing on official example redux-form-material-ui repo. code looks that:

import react 'react'; import { field } 'redux-form'; import { textfield } 'redux-form-material-ui';  export default class formtextfield extends react.component {    constructor(props) {     super(props);   }    componentwillupdate(nextprops) {     const { name, withref, focus } = nextprops;     if (withref && focus) {       this.refs[name]         .getrenderedcomponent()         .getrenderedcomponent()         .focus();     }   }    render() {     const { name, label, errortext, withref } = this.props;      return (       <field         name={name}         component={textfield}         hinttext={label}         floatinglabeltext={label}         errortext={errortext}         ref={name}         withref={withref}       />     );   } } 

i'm passing focus , withref properties first field error. on field error: uncaught (in promise) error: if want access getrenderedcomponent(), must specify withref prop field(…)

i' able, see both ref , withref passed field. in component ref="wrappedinstance" can still see withref="true". not passed deeper.

i appreciate thoughts how solve it.

  1. you needn't make ref prop, local component. can call ref="field" if wish. although not problem.
  2. also, might passing withref time.

it sounds wanting call focus() when focus prop changes false true. that, should doing like:

componentwillupdate(nextprops) {   if (!this.props.focus && nextprops.focus) {     this.refs.field       .getrenderedcomponent()       .getrenderedcomponent()       .focus()   } } 

does help?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -