Coder Social home page Coder Social logo

woody-morgan / suspensive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from toss/suspensive

0.0 0.0 0.0 517.3 MB

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

Home Page: https://suspensive.org

License: MIT License

Shell 0.06% JavaScript 3.54% TypeScript 96.07% CSS 0.33%

suspensive's Introduction



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.

suspensive's People

Contributors

manudeli avatar dependabot[bot] avatar github-actions[bot] avatar renovate[bot] avatar minsoo-web avatar okinawaa avatar tooooo1 avatar ssi02014 avatar codebutler avatar sukvvon avatar kanary159357 avatar jinn2u avatar seokkamoni avatar sungh0lim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.