React dialog : Cannot read property 'state' of undefined

For my application I have coded a put in place a login form and there is no problem.

Here is the sandbox of what I coded:

Now I’m trying to replace this login form with a material UI form dialog. I followed the example and the dialog button and form dialog do appear, but I have the following error when I open the dialog:

Type error: Cannot read property 'state' of undefined

Here is the sandbox of what I code for that:

Here I just added a Dialog.js file by following the material UI website example, imported in it the functions login and handleInput from Login.jsx and changed the render of my Login.jsx.

I have done some research about this error but most answers were to bind the functions which didn’t work in my case.

So I would like to ask some help please, because I really don’t know what to do :/.

I thank in advance anybody who will take the time to help me.

I copy/pasted your code and couldn’t see the error.
Use to create a working example.

@jenovs Ok thanks for the advice :smiley: . I just edited the post .

You shouldn’t export handlers, but pass them as props:

// Login.jsx
<Dialog handleInput={this.handleInput} login={this.login} />
1 Like