Conversation
… because of isMounted's side effect
👷 Deploy request for slash-libraries pending review.Visit the deploys page to approve it
|
|
|
||
| class BaseErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> { | ||
| state = initialState; | ||
| updatedWithError = false; |
There was a problem hiding this comment.
I thought this BaseErrorBoundary.updatedWithError is unnecessary field, there is no updatedWithError in https://github.com/bvaughn/react-error-boundary/blob/master/src/ErrorBoundary.ts too.
If this is matter, let me know why meaningful please.
| resetState() { | ||
| this.updatedWithError = false; | ||
| this.setState(initialState); | ||
| } | ||
|
|
There was a problem hiding this comment.
I remove this method BaseErrorBoundary.resetState. if no updatedWithError field, resetState is not anymore meaningful too.
I thought this.setState(initialState) is better to express what this is.
| /** @tossdocs-ignore */ | ||
| import { usePrevious } from '@toss/react'; | ||
|
|
||
| export const useIsChanged = (value: unknown) => usePrevious(value) !== value; |
There was a problem hiding this comment.
I made custom hook, useIsChanged to check whether value is changed with previous rendering value.
this hook will check parent ErrorBoundaryGroup.resetKey is changed
If parentErrorBoundaryGroup.resetKey is changed, ErrorBoundaryGroup self will change resetkey to propagate to child ErrorBoundaryGroup recursively.
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
…unnecessary-rerender
|
@manudeli is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
…unnecessary-rerender
related with toss/suspensive#92
Remove ErrorBoundaryGroup's not on purpose reset because of isMounted's side effect
useIsMounted of @toss/react is implemented by useState, but we don't need to use useIsMounted triggering rerender component self when after mount.
useIsMountedof @toss/reactbefore this Pull Request, ErrorBoundaryGroup used useIsMounted to prevent reseting ErrorBoundaryGroup self on first rendering, and after mounting and checked whether parent ErrorBoundaryGroup.resetKey is changed to reset self.
but after this Pull Request is merging, we don't need to make unnecessary rerendering due to useIsMounted.
In addition, we can prevent unintended ErrorBoundaryGroup resetting by useIsMounted.
When first I add this ErrorBoundaryGroup in @toss/error-boundary, I couldn't consider useIsMounted's rerendering side effect
AS-IS
ErrorBoundaryGroup will trigger reset on render because of useIsMounted
TO-BE
ErrorBoundaryGroup won't trigger reset on render because of removed useIsMounted
Check more detail and procedure to add this Pull Request in toss/suspensive#92 please
PR Checklist