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: https://codesandbox.io/s/react-login-auth-forked-42c97

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: https://codesandbox.io/s/react-login-auth-forked-r06ht

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 https://codesandbox.io/ 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