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

Migrate Wallet State Into React #54

Closed
lewis-sqa opened this issue Jan 13, 2022 · 1 comment · Fixed by #120
Closed

Migrate Wallet State Into React #54

lewis-sqa opened this issue Jan 13, 2022 · 1 comment · Fixed by #120
Assignees
Labels
change-request A request to change an existing component or feature

Comments

@lewis-sqa
Copy link
Contributor

lewis-sqa commented Jan 13, 2022

Description

I’ve noticed a few major problems with the implementation of state in this project. The main source of state is stored in a “global” (if we ignore the require cache) module here. The problem with this approach is React doesn’t own this object so it’s unable to respond to changes made to it. This leads to inconsistencies in the view layer and the underlying state model.

My proposed solution is to migrate this state object into the React realm either by using a store pattern (using context) or multiple useState hooks directly in a persistently mounted top-level component.

Before this work can commence, we need to address another design problem I’ve identified in the ModalHelper module here. This module needs to move away from modifying DOM elements directly - this is the job of React and can be done more effectively this way. The visibility of the modal and particular sections would become useState variables within the component(s). See #56 for more detail.

Acceptance Criteria

  • Changes to state are immediately reflected in the UI.
  • State is no longer global. This will technically mean new instances of the wallet selector are encapsulated. However, the idea of multiple wallet selectors needs to be addressed in another ticket - this should not be possible(?).
  • References to local storage values should be removed from state. Currently values such as isSignedIn and signedInwalletId are only evaluated when the module is first imported (when NearWalletSelector is imported). Logic that relies on this will be susceptible to out-of-date values which ultimately cause bugs in the long run.
@AmmarHumackicSQA AmmarHumackicSQA added the change-request A request to change an existing component or feature label Jan 19, 2022
@lewis-sqa lewis-sqa added this to the React Best Practices milestone Jan 28, 2022
@lewis-sqa lewis-sqa self-assigned this Jan 28, 2022
@lewis-sqa
Copy link
Contributor Author

This task has been moved to blocked as we need to solve some of the bigger architectural problems in the project. Once we have all 3 wallets working, we can look to solve the state issues.

@lewis-sqa lewis-sqa linked a pull request Feb 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change-request A request to change an existing component or feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants