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

v3 #1423

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft

v3 #1423

wants to merge 30 commits into from

Conversation

manudeli
Copy link
Member

@manudeli manudeli commented Jan 30, 2025

close #1108 close #1349 close #1325

Suspensive v3

PR Checklist

  • I did below actions if need
  1. I read the Contributing Guide
  2. I added documents and tests.

Copy link

coauthors bot commented Jan 30, 2025

People can be co-author:

Candidate Reasons Count Add this as commit message
@manudeli #1423 (comment) #1423 (comment) #1423 (review) #1423 (review) #1423 (comment) #1423 6 Co-authored-by: manudeli <61593290+manudeli@users.noreply.github.com>
@codecov-commenter #1423 (comment) 1 Co-authored-by: codecov-commenter <65553080+codecov-commenter@users.noreply.github.com>

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:26am
v1.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:26am
v3.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:26am
visualization.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:26am

Copy link

github-actions bot commented Jan 30, 2025

Size Change: -8.32 kB (-12.04%) 👏

Total Size: 60.7 kB

Filename Size Change
packages/react-query-4/dist/index.cjs 1.65 kB -210 B (-11.3%) 👏
packages/react-query-4/dist/index.js 372 B -22 B (-5.58%)
packages/react-query-4/dist/QueryErrorBoundary.cjs 0 B -1.12 kB (removed) 🏆
packages/react-query-4/dist/QueryErrorBoundary.js 0 B -142 B (removed) 🏆
packages/react-query-4/dist/queryOptions.js 136 B +1 B (+0.74%)
packages/react-query-4/dist/SuspenseInfiniteQuery.cjs 1.07 kB +14 B (+1.33%)
packages/react-query-4/dist/SuspenseQuery.cjs 1.06 kB +13 B (+1.25%)
packages/react-query-4/dist/useSuspenseInfiniteQuery.cjs 845 B +12 B (+1.44%)
packages/react-query-4/dist/useSuspenseQuery.cjs 838 B +14 B (+1.7%)
packages/react-query-5/dist/index.cjs 1.36 kB -397 B (-22.56%) 🎉
packages/react-query-5/dist/index.js 370 B -21 B (-5.37%)
packages/react-query-5/dist/QueryErrorBoundary.cjs 0 B -1.12 kB (removed) 🏆
packages/react-query-5/dist/QueryErrorBoundary.js 0 B -142 B (removed) 🏆
packages/react-query-5/dist/SuspenseQuery.js 136 B -1 B (-0.73%)
packages/react/dist/ClientOnly.cjs 1.07 kB +338 B (+46.05%) 🚨
packages/react/dist/DefaultProps.cjs 1.04 kB -9 B (-0.86%)
packages/react/dist/Delay.cjs 1.52 kB +292 B (+23.68%) 🚨
packages/react/dist/Delay.js 158 B -1 B (-0.63%)
packages/react/dist/DevMode.cjs 0 B -530 B (removed) 🏆
packages/react/dist/DevMode.js 0 B -131 B (removed) 🏆
packages/react/dist/ErrorBoundary.cjs 2.9 kB +172 B (+6.3%) 🔍
packages/react/dist/ErrorBoundary.js 205 B +1 B (+0.49%)
packages/react/dist/ErrorBoundaryGroup.cjs 1.64 kB +262 B (+19.04%) ⚠️
packages/react/dist/ErrorBoundaryGroup.js 196 B +1 B (+0.51%)
packages/react/dist/index.cjs 4.04 kB -269 B (-6.24%)
packages/react/dist/index.js 311 B -56 B (-15.26%) 👏
packages/react/dist/Suspense.cjs 1.44 kB +149 B (+11.53%) ⚠️
packages/react/dist/Suspensive.cjs 0 B -1.26 kB (removed) 🏆
packages/react/dist/Suspensive.js 0 B -175 B (removed) 🏆
packages/react/dist/wrap.cjs 0 B -3.77 kB (removed) 🏆
packages/react/dist/wrap.js 0 B -209 B (removed) 🏆
ℹ️ View Unchanged
Filename Size
packages/jotai/dist/Atom.cjs 660 B
packages/jotai/dist/Atom.js 115 B
packages/jotai/dist/AtomValue.cjs 647 B
packages/jotai/dist/AtomValue.js 120 B
packages/jotai/dist/index.cjs 753 B
packages/jotai/dist/index.js 158 B
packages/jotai/dist/SetAtom.cjs 645 B
packages/jotai/dist/SetAtom.js 118 B
packages/react-dom/dist/FadeIn.cjs 2.16 kB
packages/react-dom/dist/FadeIn.js 139 B
packages/react-dom/dist/index.cjs 2.38 kB
packages/react-dom/dist/index.js 176 B
packages/react-dom/dist/InView.cjs 2.12 kB
packages/react-dom/dist/InView.js 130 B
packages/react-dom/dist/useFadeIn.cjs 2.06 kB
packages/react-dom/dist/useFadeIn.js 133 B
packages/react-dom/dist/useInView.cjs 1.89 kB
packages/react-dom/dist/useInView.js 120 B
packages/react-native/dist/index.cjs 619 B
packages/react-native/dist/index.js 122 B
packages/react-native/dist/TestText.cjs 612 B
packages/react-native/dist/TestText.js 119 B
packages/react-query-4/dist/infiniteQueryOptions.cjs 548 B
packages/react-query-4/dist/infiniteQueryOptions.js 144 B
packages/react-query-4/dist/Mutation.cjs 821 B
packages/react-query-4/dist/Mutation.js 132 B
packages/react-query-4/dist/PrefetchInfiniteQuery.cjs 722 B
packages/react-query-4/dist/PrefetchInfiniteQuery.js 155 B
packages/react-query-4/dist/PrefetchQuery.cjs 712 B
packages/react-query-4/dist/PrefetchQuery.js 147 B
packages/react-query-4/dist/QueryClientConsumer.cjs 665 B
packages/react-query-4/dist/QueryClientConsumer.js 140 B
packages/react-query-4/dist/queryOptions.cjs 540 B
packages/react-query-4/dist/SuspenseInfiniteQuery.js 155 B
packages/react-query-4/dist/SuspenseQueries.cjs 928 B
packages/react-query-4/dist/SuspenseQueries.js 149 B
packages/react-query-4/dist/SuspenseQuery.js 147 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.cjs 648 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.js 148 B
packages/react-query-4/dist/usePrefetchQuery.cjs 639 B
packages/react-query-4/dist/usePrefetchQuery.js 140 B
packages/react-query-4/dist/useSuspenseInfiniteQuery.js 148 B
packages/react-query-4/dist/useSuspenseQueries.cjs 837 B
packages/react-query-4/dist/useSuspenseQueries.js 142 B
packages/react-query-4/dist/useSuspenseQuery.js 140 B
packages/react-query-5/dist/infiniteQueryOptions.cjs 573 B
packages/react-query-5/dist/infiniteQueryOptions.js 144 B
packages/react-query-5/dist/Mutation.cjs 821 B
packages/react-query-5/dist/Mutation.js 132 B
packages/react-query-5/dist/PrefetchInfiniteQuery.cjs 647 B
packages/react-query-5/dist/PrefetchInfiniteQuery.js 145 B
packages/react-query-5/dist/PrefetchQuery.cjs 639 B
packages/react-query-5/dist/PrefetchQuery.js 137 B
packages/react-query-5/dist/QueryClientConsumer.cjs 663 B
packages/react-query-5/dist/QueryClientConsumer.js 140 B
packages/react-query-5/dist/queryOptions.cjs 563 B
packages/react-query-5/dist/queryOptions.js 136 B
packages/react-query-5/dist/SuspenseInfiniteQuery.cjs 833 B
packages/react-query-5/dist/SuspenseInfiniteQuery.js 145 B
packages/react-query-5/dist/SuspenseQueries.cjs 671 B
packages/react-query-5/dist/SuspenseQueries.js 139 B
packages/react-query-5/dist/SuspenseQuery.cjs 825 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.cjs 577 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.js 148 B
packages/react-query-5/dist/usePrefetchQuery.cjs 569 B
packages/react-query-5/dist/usePrefetchQuery.js 140 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.cjs 577 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.js 148 B
packages/react-query-5/dist/useSuspenseQueries.cjs 571 B
packages/react-query-5/dist/useSuspenseQueries.js 142 B
packages/react-query-5/dist/useSuspenseQuery.cjs 569 B
packages/react-query-5/dist/useSuspenseQuery.js 140 B
packages/react-query/dist/index.cjs 552 B
packages/react-query/dist/index.js 121 B
packages/react-query/dist/v4.cjs 550 B
packages/react-query/dist/v4.js 116 B
packages/react-query/dist/v5.cjs 550 B
packages/react-query/dist/v5.js 116 B
packages/react/dist/ClientOnly.js 141 B
packages/react/dist/DefaultProps.js 167 B
packages/react/dist/Suspense.js 171 B

compressed-size-action

@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.73%. Comparing base (95088d8) to head (f00fbe0).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main    #1423       +/-   ##
=========================================
+ Coverage      0   77.73%   +77.73%     
=========================================
  Files         0       66       +66     
  Lines         0      548      +548     
  Branches      0      121      +121     
=========================================
+ Hits          0      426      +426     
- Misses        0      117      +117     
- Partials      0        5        +5     
Components Coverage Δ
@suspensive/react 97.77% <94.52%> (∅)
@suspensive/react-dom 95.60% <ø> (∅)
@suspensive/react-native 100.00% <ø> (∅)
@suspensive/react-query 83.47% <ø> (∅)
@suspensive/react-query-4 0.00% <ø> (∅)
@suspensive/react-query-5 0.00% <ø> (∅)
@suspensive/jotai 0.00% <ø> (∅)
@suspensive/codemods 67.03% <ø> (∅)

Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: f00fbe0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@suspensive/codemods Major
@suspensive/react Major
@suspensive/react-query Major
@suspensive/react-query-4 Major
@suspensive/react-query-5 Major
@suspensive/jotai Major

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

Co-authored-by: Poco <23068523+pocojang@users.noreply.github.com>
Co-authored-by: Juhyeok Kang <23312485+kangju2000@users.noreply.github.com>
…error (#1409)

🚧 This PR could make a huge difference, so please help us make sure this
change gets a very thorough review. 🚧

```tsx
const Throw = {
  Error: ({ message, after = 0, children }: PropsWithChildren<{ message: string; after?: number }>) => {
    const [isNeedThrow, setIsNeedThrow] = useState(after === 0)
    if (isNeedThrow) {
      throw new Error(message)
    }
    useTimeout(() => setIsNeedThrow(true), after)
    return <>{children}</>
  }
}

const Example = () => (
  <ErrorBoundary fallback={() => <>This is expected</>}>
    <ErrorBoundary
      fallback={() => (
        <Throw.Error message={ERROR_MESSAGE} after={100}>
          ErrorBoundary's fallback before error
        </Throw.Error>
      )}
    >
      <Throw.Error message={ERROR_MESSAGE} after={100}>
        ErrorBoundary's children before error
      </Throw.Error>
    </ErrorBoundary>
  </ErrorBoundary>
)
```

## Problem: ErrorBoundary's fallback can't be treated by parent
ErrorBoundary

<!--
    A clear and concise description of what this pr is about.
 -->
 
Thrown Error in fallback will be caught by ErrorBoundary self and then
expose fallback recursively 🥲
1. ErrorBoundary's children before error
2. ErrorBoundary's fallback before error
3. ErrorBoundary's fallback before error
4. ErrorBoundary's fallback before error
5. ... expose fallback self recursively ... 

## Solution: When we meet thrown error in fallback of ErrorBoundary wrap
it as InternalFallbackError, re-throw
InternalFallbackError.fallbackError, if it is InternalFallbackError

Thrown Error in fallback will be caught by parent ErrorBoundary 👍
1. ErrorBoundary's children before error
2. ErrorBoundary's fallback before error
3. This is expected 

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md)
5. I added documents and tests.

---------

Co-authored-by: Lee HyunJae (whale) <71202076+2-NOW@users.noreply.github.com>
Co-authored-by: lucas0530 <23375098+lucas0530@users.noreply.github.com>
Co-authored-by: HYUNGU KANG <69349293+linegu@users.noreply.github.com>
Co-authored-by: Brian Vaughn <29597+bvaughn@users.noreply.github.com>
close #1451 

# with as method

<!--
    A clear and concise description of what this pr is about.
 -->

There were two reasons why withXXX was inconvenient (
#270 )
1. It was inconvenient to read in the case of nested hoc by receiving
xxxProps as the second argument
2. I thought it was difficult to read in the case of nested Suspense,
ErrorBoundary, etc.

## v1 withXXX
```tsx
export default withErrorBoundary(
  withSuspense(
    () => {
     /**
      * 
      * 
      * 
      * Many implementation will be here
      * 
      * 
      *  
      */

      return 'success'
    },
    { fallback: 'loading…' } // far position with name of withSuspense
  ),
  { fallback: () => 'error' } // far position with name of withErrorBoundary
)
```

## v2 wrap.XXX
```tsx
export default wrap
  .ErrorBoundary({ fallback: () => 'error' }) // Good to read
  .Suspense({ fallback: 'loading…' }) // Good to read
  .on(() => {  // But users need to know builder pattern
     /**
      * 
      * 
      * 
      * Many implementation will be here
      * 
      * 
      *  
      */

      return 'success'
    })
```

Because of these two points, I thought that the code would be readable
if I made it with wrap builder, but when library users actually used v2
wrap, they didn't understand how to use it nestedly or how to use wrap
well.

So I want to change it to a with method for each component like below
code so that it receives props first, although it's simple.
1. I want to make props are received first.
2. I don't want it to be a builder.

## v3 XXX.with
```tsx
export default ErrorBoundary.with({ fallback: () => 'error' },  // Good to read
  Susepnse.with({ fallback: 'loading…' }, () => {  // Good to read
   /**
    * 
    * 
    * 
    * Many implementation will be here
    * 
    * 
    *  
    */

    return 'success'
  })
)
```

## 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 next, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @suspensive/react@3.0.0-next.3

### Major Changes

- [#1452](#1452)
[`79cfd61`](79cfd61)
Thanks [@manudeli](https://github.com/manudeli)! - feat(react): with as
method

## @suspensive/react-query@3.0.0-next.3

### Patch Changes

-   Updated dependencies \[]:
    -   @suspensive/react-query-4@3.0.0-next.3
    -   @suspensive/react-query-5@3.0.0-next.3

## @suspensive/jotai@3.0.0-next.3



## @suspensive/react-query-4@3.0.0-next.3



## @suspensive/react-query-5@3.0.0-next.3
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

## PR Checklist

- [ ] 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 next, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @suspensive/react@3.0.0-next.4

### Patch Changes

- [#1455](#1455)
[`05a9759`](05a9759)
Thanks [@manudeli](https://github.com/manudeli)! - fix(react): fix wrong
interface of with method

## @suspensive/react-query@3.0.0-next.4

### Patch Changes

-   Updated dependencies \[]:
    -   @suspensive/react-query-4@3.0.0-next.4
    -   @suspensive/react-query-5@3.0.0-next.4

## @suspensive/jotai@3.0.0-next.4



## @suspensive/react-query-4@3.0.0-next.4



## @suspensive/react-query-5@3.0.0-next.4
# Overview

closed: #1442 

In React Query v4, the `OnlineManager` checks the client's network
status using `navigator.onLine`. However, this can sometimes cause bugs
in Chrome (Chromium-based browsers), where the network is incorrectly
detected as offline even when it is online.

To minimize this issue, React Query v5 no longer relies on
`navigator.onLine`.

In React Query v4, to minimize this issue, **networkMode is set to
always in Suspense Hooks**. This change ensures that TData in Suspense
remains guaranteed.

ref:

-
https://github.com/TanStack/query/blob/v4/packages/query-core/src/onlineManager.ts#L92
- TanStack/query#4753
- https://issues.chromium.org/issues/338514113

## 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 next, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @suspensive/react-query-4@3.0.0-next.5

### Major Changes

- [#1458](#1458)
[`c78cbfd`](c78cbfd)
Thanks [@gwansikk](https://github.com/gwansikk)! - feat(react-query-4):
set network mode to always

## @suspensive/react-query@3.0.0-next.5

### Patch Changes

- Updated dependencies
\[[`c78cbfd`](c78cbfd)]:
    -   @suspensive/react-query-4@3.0.0-next.5
    -   @suspensive/react-query-5@3.0.0-next.5

## @suspensive/jotai@3.0.0-next.5



## @suspensive/react@3.0.0-next.5



## @suspensive/react-query-5@3.0.0-next.5
# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

#1387 (comment)

## 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: Gwansik Kim <39869096+gwansikk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants