Forum Discussion

jay chadwell's avatar
jay chadwell
Copper Contributor
Dec 23, 2020
Solved

Unable to pass data from React component to webpart ts file

I have been unable to pass data from a react component back to the webpart ts using a function passed into props. I created the simplest example of this and continue to get the following error: Type...
  • jay chadwell's avatar
    Dec 23, 2020

    jay chadwell 

     

    Ok solved it by looking at this article:

    https://www.voitanos.io/blog/deal-with-undefined-this-react-event-handler-performant-way/

     

    added  a bind statement in the constructor of the react component so that the passData function has proper reference to "this".

     

      constructor(propsISync1Props) {
        super(props);
        this.passData = this.passData.bind(this);

      }

Resources