Skip to content
forked from toss/suspensive

Packages to use React Suspense & ErrorBoundary easily (one of Tanstack Query v4's community resources)

License

Notifications You must be signed in to change notification settings

Kanary159357/react

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



npm version npm npm bundle size

All declarative components to use suspense on both CSR, SSR.

Features

  • Suspense
  • ErrorBoundary, useErrorBoundary, useErrorBoundaryFallbackProps
  • ErrorBoundaryGroup, useErrorBoundaryGroup
  • Delay
  • SuspensiveProvider, Suspensive
  • DevMode

Installation

npm install @suspensive/react
pnpm add @suspensive/react
yarn add @suspensive/react

Usage

import { Suspense, ErrorBoundary, ErrorBoundaryGroup, Delay } from '@suspensive/react'

const Example = () => (
  <ErrorBoundaryGroup>
    <ErrorBoundaryGroup.Consumer>
      {(group) => <Button onClick={group.reset}>Reset All</Button>}
    </ErrorBoundaryGroup.Consumer>
    <ErrorBoundary
      fallback={(props) => (
        <>
          <button onClick={props.reset}>Try again</button>
          {props.error.message}
        </>
      )}
    >
      <Suspense
        fallback={
          <Delay>
            <Spinner />
          </Delay>
        }
      >
        <SuspendedComponent />
      </Suspense>
    </ErrorBoundary>
  </ErrorBoundaryGroup>
)


npm version npm npm bundle size

Declarative apis to use @tanstack/react-query with suspense easily.

Features

  • useSuspenseQuery
  • useSuspenseQueries
  • useSuspenseInfiniteQuery
  • QueryErrorBoundary

Installation

npm install @suspensive/react-query
pnpm add @suspensive/react-query
yarn add @suspensive/react-query

Usage

import { Suspense } from '@suspensive/react'
import { QueryErrorBoundary, useSuspenseQuery } from '@suspensive/react-query'

const Example = () => (
  <QueryErrorBoundary
    fallback={(props) => (
      <>
        <button onClick={props.reset}>Try again</button>
        {props.error.message}
      </>
    )}
  >
    <Suspense fallback={<Spinner />}>
      <SuspendedComponent />
    </Suspense>
  </QueryErrorBoundary>
)

const SuspendedComponent = () => {
  const query = useSuspenseQuery({
    queryKey,
    queryFn,
  })

  return <>{query.data}</>
}

Docs deployment

We provide Official Docs

See OFFICIAL DOCS


Visualization deployment

Concepts Visualization ready. You can see core concepts of Suspensive visually

See VISUALIZATION.


Contributing

Read our Contributing Guide to familiarize yourself with Suspensive's development process, how to suggest bug fixes and improvements, and the steps for building and testing your changes.

Contributors

contributors


License

MIT © Suspensive. See LICENSE for details.

About

Packages to use React Suspense & ErrorBoundary easily (one of Tanstack Query v4's community resources)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.0%
  • JavaScript 3.6%
  • Other 0.4%