FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

unfold/fetch-data: Declarative data fetching for Redux and React · GitHub

This repository was archived by the owner on Mar 6, 2023. It is now read-only.
/ fetch-data Public archive

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fetch Data

Declarative data fetching for Redux and React.

Install

npm

npm install --save-dev @unfold/fetch-data

yarn

yarn add --dev @unfold/fetch-data

Usage

1. Add middleware to Redux store

import { createFetchMiddleware } from '@unfold/fetch-data'

const store = createStore(reducers, initialState, applyMiddleware(thunk, createFetchMiddleware()))

2. Create reducers for requests and entities

import { createRequestsReducer, createEntityReducer } from '@unfold/fetch-data'
import { combineReducers } from 'redux'

const reducers = combineReducers({
  requests: createRequestsReducer(),
  posts: createEntityReducer('LIST_POSTS')
})

3. Add declarative data requirements to your components

import fetchData, { createFetchAction } from '@unfold/fetch-data'

const listPosts = () => createFetchAction({
  url: 'http://api.io/posts'
})

const ProfileContainer = fetchData({
  mapPropsToAction: () => listPosts()
}, {
  mapStateToProps: ({ posts }) => posts
})

About

Declarative data fetching for Redux and React

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL