Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SetState method is not working

See original GitHub issue


I’m using the setState method but it seems it doesn’t work. actually, always the state value is equal to the default value!

        { currentUser: loggedInUser },

after setState when I’m subscribing to my state class state value is always equal to the default value!!

  constructor(private authService: AuthService) {
    this.subs.sink = this.authService.stateChanged.subscribe((state) => {
      console.log('user panel sate', state);
      this.user = state.currentUser ?? null;

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

DanWahlincommented, Jul 8, 2021

No problem. Sorry I don’t have that feature now. I doubt it’ll ever be in the core package but could potentially be an add-on package some day.

hamidh2commented, Jul 8, 2021

Thank you @DanWahlin I confess that you reply very quickly and it was very awesome for me! hope to provide that part for the package very soon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does calling react setState method not mutate the state ...
setState () does not immediately mutate this.state but creates a pending state transition. Accessing this.state after calling this method can potentially ...
Read more >
Why my setState doesn't work? - Sergey Stadnik
setState operation is asynchronous in React. If you new state depends on the values of the old state, you should use a functional...
Read more >
Why does setState() not work in my React app? - Medium
Whenever state needs to be calculated based on a previous state, it's unsafe to pass an object to setState () . Because this.state...
Read more >
ReactJS setState() - GeeksforGeeks
setState is asynchronous call means if synchronous call get called it may not get updated at right time like to know current value...
Read more >
React Error: "this.setstate is not a function" - How to Fix
However, when we click it, we get an error. We'll get something like “this.setState is not a function” or “cannot read property 'setState'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found