Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a state management library #488

Open
SilviaZeta opened this issue Dec 8, 2021 · 3 comments
Open

Introduce a state management library #488

SilviaZeta opened this issue Dec 8, 2021 · 3 comments
Assignees
Labels
feature [Improvement] New feature request. major [Release] Major release. question [Problem] Further help and/or information is required.

Comments

@SilviaZeta
Copy link
Contributor

Considerations

With React router, a route can change while some async operation (for example, fetching some data from STORE) is still ongoing. This causes setState to be invoked when the component is dismounted and leads to the React warning “Can’t perform a React state update on an unmounted component”.

For now we have handled this issue by skipping the setState operation if a component is unmounted (with theisMounted workaround), but this is not a best practice. We have also considered canceling the async operations (i.e., API calls), but we are unhappy with this second solution, because it makes it hard to handle any side-effects, as these vary between operations and depend on the point at which an operation is interrupted.

Storing states to a centralised store is a better solution, as it allows to decouple state management from the component lifecycle and has the extra benefit of reducing the number of API calls required for the app to work.

Alternatives we have considered

We could also move the state management async code up in your component tree, although not clear how to do this in the context of a React router design.

@SilviaZeta SilviaZeta added enhancement [Improvement] Enhancement request. major [Release] Major release. labels Dec 8, 2021
@ChasNelson1990
Copy link
Member

Could we keep the state management out of ANNOTATE/CURATE/MANAGE/AUDIT/etc.? If so, is 2022 the right time to raise this again for discussion? Or shall we mark as wontfix for now?

@cooper667
Copy link
Contributor

I think it's something we want at some point. I don't know if that point is now, but we should talk about it.

@ChasNelson1990 ChasNelson1990 changed the title Intruduce a state management library Introduce a state management library Jan 12, 2022
@ChasNelson1990
Copy link
Member

Just discussed: more like a cache than a state management store

@ChasNelson1990 ChasNelson1990 added the question [Problem] Further help and/or information is required. label Jan 12, 2022
@joshuajames-smith joshuajames-smith added feature [Improvement] New feature request. and removed enhancement [Improvement] Enhancement request. labels Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [Improvement] New feature request. major [Release] Major release. question [Problem] Further help and/or information is required.
Projects
None yet
Development

No branches or pull requests

7 participants