-
Notifications
You must be signed in to change notification settings - Fork 9
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
File structure and components refactoring and test update #215
Merged
renintw
merged 9 commits into
trunk
from
refactor/structure-components-refactoring-and-test-update
Jun 15, 2023
Merged
File structure and components refactoring and test update #215
renintw
merged 9 commits into
trunk
from
refactor/structure-components-refactoring-and-test-update
Jun 15, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 tasks
renintw
force-pushed
the
add/handle-revalidation-error-in-a-single-place
branch
2 times, most recently
from
June 9, 2023 14:41
5add378
to
7107688
Compare
Base automatically changed from
add/handle-revalidation-error-in-a-single-place
to
trunk
June 9, 2023 14:51
renintw
force-pushed
the
refactor/structure-components-refactoring-and-test-update
branch
2 times, most recently
from
June 9, 2023 14:57
760debf
to
6e16e3c
Compare
iandunn
approved these changes
Jun 14, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
Hook should be called by a component. In test, renderHook would do that for us.
navigateToScreen should be added as the hook dependency, or hasEdits might not be the latest value when calling the function. In fact, due to the property of how hasEdits is updated, the navigateToScreen would always get the latest value of hasEdits, but it's best practice to add state and props that are used in the hook as its dependency, or it might get harder to develop new feature or maintain the code someday in the future.
renintw
force-pushed
the
refactor/structure-components-refactoring-and-test-update
branch
from
June 15, 2023 02:51
6e16e3c
to
d755597
Compare
renintw
deleted the
refactor/structure-components-refactoring-and-test-update
branch
June 15, 2023 02:58
renintw
restored the
refactor/structure-components-refactoring-and-test-update
branch
June 22, 2023 18:48
renintw
deleted the
refactor/structure-components-refactoring-and-test-update
branch
June 22, 2023 18:49
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #210
This PR refactors the items mentioned in #210 as well as the following ones
renderHook
for useUser test.In testing, using
renderHook
is recommended as it simulates a true React environment for Hooks. While some Hooks likeuseSelect
anduseEntityRecord
may work outside a true React environment because their functions aren't tied to the React lifecycle, it's not guaranteed. For lifecycle-dependent Hooks likeuseEffect
, a real React environment is necessary. Therefore, always use tools like renderHook
in tests for accurate simulations, even if some tests pass without them.This is an issue discovered in #205.
This is an issue discovered in #205.
@wordpress/scripts
to25.5.1
3.
makes me wonder why there's no warning/error for not adding required dependencies to a hook, then I found that the rule was added later in WordPress/gutenberg#24914 (In this PR, there are some discussions about whether to enable the rule). Since our version of@wordpress/scripts
is pinned to24
, it can't reflect the update on Gutenberg side. The latest version of@wordpress/scripts
is26.6.0
at the moment, but it wasn't upgraded to that version in this PR as there'd be failures when doing js testing. The root cause of it might come from the older version of@wordpress/core-data
. At the moment, I guess it's not absolutely necessary to bump the version to26.6.0
, as the rule I really want to introduce is'react-hooks/exhaustive-deps': 'warn',
which still exists in the latest version. We could address it when it really needs to.