Skip to content
/ xswr Public

😇 A data fetching solution for React Hooks and Imperative Ajax request

Notifications You must be signed in to change notification settings

red-armor/xswr

Repository files navigation

English | 简体中文

xswr

A data fetching solution for React Hooks and Imperative Ajax request

npm version NPM downloads code style: prettier

Introduction

xswr is inspired by swr and documentation HTTP RFC 5861 mentioned in its readme file. In general, comparing with swr, xswr has following features

  1. Scenario, applicable for React Hooks and Promise-base Ajax request
  2. Isolated Configuration Context, fetcher is identified by key param and shared by items with same key, config is isolated from each other.
  3. Re-render control, In React Hooks, it is configurable to control whether re-render component or not caused by data change.
  4. Easy to use, In Promise-based Ajax chain request, retry and pooling could be performed automatically.

Installation

With npm

npm install xswr

With yarn

yarn add xswr

How does xswr works

basic mechanism

Usage

  1. useXS - React Hooks solution
  2. xs - Promise-based Ajax solution