flatlogic / react-material-admin

☄️React Material Admin is a React template built with Material-UI
https://flatlogic.com/admin-dashboards/react-material-admin/demo
MIT License
1.6k stars 559 forks source link

UserContext may call a warning #14

Closed ppxb closed 4 years ago

ppxb commented 4 years ago

in function loginUser if you write like this

if (!!username && !!password) {
    setTimeout(() => {
      localStorage.setItem('id_token', 1)
      dispatch({ type: 'LOGIN_SUCCESS' })
      setError(null)
      setIsLoading(false)

      histroy.push('/app/dashboard')
    }, 2000)
}

may call a warning likes Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

but write like this

if (!!username && !!password) {
    setTimeout(() => {
      localStorage.setItem('id_token', 1)
      setError(null)
      setIsLoading(false)
      dispatch({ type: 'LOGIN_SUCCESS' })

      histroy.push('/app/dashboard')
    }, 2000)

it will not.

michaeldaineka commented 4 years ago

Hi there!

Thanks for your help!

We've already pushed a commit that contains your implementation of the React error message