reactjs - es6 setprops is not a function -
class mycomponent { constructor(props){ super(props); } render() { return <view /> } } class test() { constructor(props){ super(props); this.onclick = this.onclick.bind(this); } onclick() { this.my.setporps({ show: true, }); } render(){ return <mycomponent ref={ ref => this.my = ref }/> } }
if trigger onclick function, cause:
undefined not function (evaluating '_this3.progressbar.setprops({ disabled:true})')
can me? lot!
from react docs:
this method deprecated , removed soon. method not available on es6 class components extend react.component. instead of calling setprops, try invoking reactdom.render() again new props.
https://facebook.github.io/react/docs/component-api.html#setprops
(also in example spelled setporps
wouldn't work anyway)
it looks trying tell component show itself, in case parent state can updated , passed prop child:
class test() { constructor(props){ super(props); this.state = { show: false }; this.onclick = this.onclick.bind(this); } onclick() { this.setstate({ show: true }); } render() { return <mycomponent show={this.state.show} /> } }
Comments
Post a Comment