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

refactor(utils): extract useReduxConnection for less repetition #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PrettyCoffee
Copy link
Contributor

Chunk of this PR: #32

This will extract the repeated logic of useAtomDevtools and useAtomsDevtools regarding the initial connection to the redux extension into a shared custom hook. It will be helpful to implement consistent behavior for both hooks. 🙂

(for example when reduxjs/redux-devtools#1370 is fixed or #32 is implemented as temporary solution or if there is any other solution for the duplicated connection problem)

This is only a refactoring, it should not introduce any behavioral changes.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 37197c8:

Sandbox Source
React Configuration
React Typescript Configuration

@arjunvegda arjunvegda requested a review from dai-shi March 19, 2023 22:38
useEffect(() => {
didMount.current = true;
}, []);
return didMount.current;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like useDidMount as a React practice. Specifically, this is violating the React rule: We shouldn't read a ref value in render.
Maybe, it was implemented so previously. This reveals it then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check if I can work around it, so I don't have to use useDidMount. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants