question-mark
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.

Difference between rendered components and app state

See original GitHub issue

I’ve been working on a small “notes” app and encounter the following issue when trying to implement “remove a note with id x feature”. I believe the bug might be more generic than just my notes app (updating state? trigger re-renders?) but this is just an easy way to expose the behaviour.

Node version: v10.15.2 @nodegui/react-nodegui: 0.1.5,

Expected: Pressing the trash icon next to a note triggers a state changes, returns an array without the given note. Therefore, the note disappears from the screen.

Observed behaviour: As seen from the console.log statements, the note correctly disappears from state. Also the “counter” on top correctly reflects the amount of notes is going down by 1. The note itself however does not disappear from remove. Repeated clicks on this or other buttons at some point will just crash the app.

What I’ve tried At first I thought it might have to do with passing the callbacks around which might not be supported from some reason. Based on the calculator example I refactored the notes app to useReducer() instead, so state is more centralised and predictable. This didn’t seem to make any difference for this bug.

Diff with relevant code changes: https://github.com/pepf/react-nodegui-starter/commit/08560d5360de78cd665f75b4a36a3186bbe52ecd

Reproduction branch: https://github.com/pepf/react-nodegui-starter/tree/notes-app

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
pepfcommented, Sep 12, 2019

Seems to work! 👌

0reactions
a7ulcommented, Sep 12, 2019

Awesome 🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between application state and ...
Application state is the "global" state that all components in the component tree can access, through cursors. This is the state that your...
Read more >
Thinking in React
The components will only have render() methods since this is a static version of your app. The component at the top of the...
Read more >
React: rendering vs running your components - Krasimir Tsonev
So, rendering a React app means running all of our functions (which we call "components") and examining their output. This may lead to...
Read more >
"mount" vs "render"? - React Training
Each component will get its own schedule of mounting and re-renders that can differ from each other. Since User is the child of...
Read more >
React State vs Props explained - codeburst
Isn't they look a lot similar ? they both generate the same output write Hey to the output the only difference between the...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found