1
this.state = {
  loading: false,
  timer: false,
  showZero: false,
  pin: '',
  error: {
    emptyPin: false,
    checkPin: false,
    wrongPin: false,
    message: '',
    devices: undefined,
    type: 999,
    checkBoxStr: '',
  },
  showDialog: false,
  showSnackBar: false,
  singleButtonDialog: false,
  disabledButton: true,
  checkBox: false,
  seconds: 0,
};

this is the State Values , i need to unmount the Values using Componentwillunmount if this possible Please let me know

i got this error

Warning: 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 the componentWillUnmount method.
in VerifyOtp (created by WithStyles(VerifyOtp))
in WithStyles(VerifyOtp) (created by Context.Consumer)
Vijay
  • 275
  • 2
  • 11
  • 4
    This sounds like an [XY Problem](https://xyproblem.info/). When a component unmounts it's state will be gone. If it gets mounted again it will have a new state object. What is the actual problem you are having? – charlietfl Jan 07 '22 at 04:31
  • Warning: 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 the componentWillUnmount method. in VerifyOtp (created by WithStyles(VerifyOtp)) in WithStyles(VerifyOtp) (created by Context.Consumer) i got this error – Vijay Jan 07 '22 at 04:34
  • What do you mean by "unmount the values"? Do you just want to reset them to their initial state? – Andy Jan 07 '22 at 04:35
  • How can i reset the initial state – Vijay Jan 07 '22 at 04:35
  • Just have an object with initial state, and then set your state with that. – Andy Jan 07 '22 at 04:37
  • please share the code snippets – Vijay Jan 07 '22 at 04:39
  • 3
    Something you are not showing us is causing the error. Put that error message into a web seaarch and you will find lots of results – charlietfl Jan 07 '22 at 04:40

0 Answers0