Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Utility components for managing fetch operations in React

License

NotificationsYou must be signed in to change notification settings

signalsciences/rsrc

Repository files navigation

Logo

Rsrc

civersionlicensegzip size

A collection of components designed to simplify fetch state in React.

Docs

Getting Started

yarn add rsrc

Usage

importReactfrom"react";import{Resource}from"rsrc";exportdefault(props)=>{const{ id}=props;consturl=`/todos/${id}`;return(<Resourceurl={url}maxAge={60}actions={{remove:()=>({options:{method:"DELETE",},invalidates:["/todos"],}),}}>{({ state, actions})=>{if(!state.fulfilled)returnnull;consttodo=state.value;consthandleClick=()=>{actions.remove().then((value)=>{/* */}).catch((error)=>{/* */});};return(<div><h1>{todo.name}</h1><p>{todo.description}</p><buttononClick={handleClick}>×</button></div>);}}</Resource>);};

Related

About

Utility components for managing fetch operations in React

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp