-
Notifications
You must be signed in to change notification settings - Fork 72
fix(react): add defineSuspense util function #1065
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
Conversation
🦋 Changeset detectedLatest commit: 2195a58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@ssi02014 is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
0bb02d6
to
4afe9af
Compare
CodSpeed Performance ReportMerging #1065 will create unknown performance changesComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1065 +/- ##
==========================================
+ Coverage 84.18% 84.23% +0.05%
==========================================
Files 51 52 +1
Lines 550 552 +2
Branches 117 117
==========================================
+ Hits 463 465 +2
Misses 82 82
Partials 5 5
|
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.
Thanks! 🚀🚀🚀
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.
@ssi02014 Double check please! I modify your Pull Request
/* eslint-disable @typescript-eslint/unified-signatures */ | ||
export function defineSuspense(options: { componentPropsClientOnly: true }): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { defaultPropsClientOnly: true }): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: true | ||
defaultPropsClientOnly: undefined | ||
}): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: undefined | ||
defaultPropsClientOnly: true | ||
}): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: true | ||
defaultPropsClientOnly: true | ||
}): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: true | ||
defaultPropsClientOnly: false | ||
}): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: false | ||
defaultPropsClientOnly: true | ||
}): typeof SuspenseClientOnly | ||
export function defineSuspense(options: { | ||
componentPropsClientOnly: false | ||
defaultPropsClientOnly: false | ||
}): typeof Suspense | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function defineSuspense(options: {}): typeof Suspense | ||
export function defineSuspense({ | ||
defaultPropsClientOnly, | ||
componentPropsClientOnly, | ||
}: { | ||
defaultPropsClientOnly?: boolean | ||
componentPropsClientOnly?: boolean | ||
}): typeof SuspenseClientOnly | typeof Suspense { | ||
return componentPropsClientOnly ?? defaultPropsClientOnly ? SuspenseClientOnly : Suspense | ||
} |
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.
I added function overriding.
describe('defineSuspense', () => { | ||
it('type check', () => { | ||
expectTypeOf(defineSuspense({ componentPropsClientOnly: true })).toEqualTypeOf<typeof SuspenseClientOnly>() | ||
expectTypeOf(defineSuspense({ defaultPropsClientOnly: true })).toEqualTypeOf<typeof SuspenseClientOnly>() | ||
expectTypeOf(defineSuspense({ componentPropsClientOnly: true, defaultPropsClientOnly: undefined })).toEqualTypeOf< | ||
typeof SuspenseClientOnly | ||
>() | ||
expectTypeOf(defineSuspense({ componentPropsClientOnly: undefined, defaultPropsClientOnly: true })).toEqualTypeOf< | ||
typeof SuspenseClientOnly | ||
>() | ||
expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: true })).toEqualTypeOf< | ||
typeof SuspenseClientOnly | ||
>() | ||
expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: false })).toEqualTypeOf< | ||
typeof SuspenseClientOnly | ||
>() | ||
expectTypeOf(defineSuspense({ defaultPropsClientOnly: false, componentPropsClientOnly: true })).toEqualTypeOf< | ||
typeof SuspenseClientOnly | ||
>() | ||
expectTypeOf(defineSuspense({ defaultPropsClientOnly: false, componentPropsClientOnly: false })).toEqualTypeOf< | ||
typeof Suspense | ||
>() | ||
expectTypeOf( | ||
defineSuspense({ defaultPropsClientOnly: undefined, componentPropsClientOnly: undefined }) | ||
).toEqualTypeOf<typeof Suspense>() | ||
}) | ||
}) |
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.
I added type test codes
expect(defineSuspense({ componentPropsClientOnly: true })).toBe(SuspenseClientOnly) | ||
expect(defineSuspense({ componentPropsClientOnly: true, defaultPropsClientOnly: undefined })).toBe( | ||
SuspenseClientOnly | ||
) | ||
}) | ||
it('should return SuspenseClientOnly when defaultPropsClientOnly is true and componentPropsClientOnly is undefined', () => { | ||
expect(defineSuspense({ defaultPropsClientOnly: true })).toBe(SuspenseClientOnly) | ||
expect(defineSuspense({ componentPropsClientOnly: undefined, defaultPropsClientOnly: true })).toBe( | ||
SuspenseClientOnly | ||
) | ||
}) |
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.
I added more test code
@manudeli Thank you for improving this task👍 I've checked it out. |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.6.1 ### Patch Changes - [#1065](#1065) [`2216377`](2216377) Thanks [@ssi02014](https://github.com/ssi02014)! - feat(react): fix clientOnly prop of Suspense with defaultProps ## @suspensive/react-query@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 - @suspensive/react-query-4@2.6.1 - @suspensive/react-query-5@2.6.1 ## @suspensive/react-query-4@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 ## @suspensive/react-query-5@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
close: #1058 # Overview Add the `defineSuspense` utility function discussed in the issue article above, and write the test code. The reason we defined `SuspenseClientOnly` within `defineSuspense` is because we are getting the `"dependency cycle detected"` issue. If you have any additional thoughts on the above issues, please let us know! ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.6.1 ### Patch Changes - [#1065](#1065) [`2216377`](2216377) Thanks [@ssi02014](https://github.com/ssi02014)! - feat(react): fix clientOnly prop of Suspense with defaultProps ## @suspensive/react-query@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 - @suspensive/react-query-4@2.6.1 - @suspensive/react-query-5@2.6.1 ## @suspensive/react-query-4@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 ## @suspensive/react-query-5@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
close: #1058 # Overview Add the `defineSuspense` utility function discussed in the issue article above, and write the test code. The reason we defined `SuspenseClientOnly` within `defineSuspense` is because we are getting the `"dependency cycle detected"` issue. If you have any additional thoughts on the above issues, please let us know! ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. ---------
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.6.1 ### Patch Changes - [#1065](#1065) [`2216377`](2216377) Thanks [@ssi02014](https://github.com/ssi02014)! - feat(react): fix clientOnly prop of Suspense with defaultProps ## @suspensive/react-query@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 - @suspensive/react-query-4@2.6.1 - @suspensive/react-query-5@2.6.1 ## @suspensive/react-query-4@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 ## @suspensive/react-query-5@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1
close: #1058 # Overview Add the `defineSuspense` utility function discussed in the issue article above, and write the test code. The reason we defined `SuspenseClientOnly` within `defineSuspense` is because we are getting the `"dependency cycle detected"` issue. If you have any additional thoughts on the above issues, please let us know! ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.6.1 ### Patch Changes - [#1065](#1065) [`2216377`](2216377) Thanks [@ssi02014](https://github.com/ssi02014)! - feat(react): fix clientOnly prop of Suspense with defaultProps ## @suspensive/react-query@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 - @suspensive/react-query-4@2.6.1 - @suspensive/react-query-5@2.6.1 ## @suspensive/react-query-4@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 ## @suspensive/react-query-5@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1
close: #1058 # Overview Add the `defineSuspense` utility function discussed in the issue article above, and write the test code. The reason we defined `SuspenseClientOnly` within `defineSuspense` is because we are getting the `"dependency cycle detected"` issue. If you have any additional thoughts on the above issues, please let us know! ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.6.1 ### Patch Changes - [#1065](#1065) [`2216377`](2216377) Thanks [@ssi02014](https://github.com/ssi02014)! - feat(react): fix clientOnly prop of Suspense with defaultProps ## @suspensive/react-query@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 - @suspensive/react-query-4@2.6.1 - @suspensive/react-query-5@2.6.1 ## @suspensive/react-query-4@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1 ## @suspensive/react-query-5@2.6.1 ### Patch Changes - Updated dependencies \[[`2216377`](2216377)]: - @suspensive/react@2.6.1
close: #1058
Overview
Add the
defineSuspense
utility function discussed in the issue article above, and write the test code.The reason we defined
SuspenseClientOnly
withindefineSuspense
is because we are getting the"dependency cycle detected"
issue.If you have any additional thoughts on the above issues, please let us know!
PR Checklist