herrherrmann / ladda-react

React helpers for Ladda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ladda-react

Ladda-react provides helper functions to easily integrate React apps with the data caching library Ladda.

Installation

npm install --save ladda-react

Higher-Order Components

withData(config)

withData is a HOC that takes a configuration object and enriches an existing component by injecting state management.

Example

import { withData } from 'ladda-react';

const config = {
    resolve: {
        mails: (props) => api.getMails(props.userId), // api.getMails() returns a promise
    },
    pendingComponent: () => <LoadingComponent />,
    errorComponent: () => <ErrorComponent />
    // ... and more! Check "Config" for more options.
};

return withData(config)(MyComponent);
// => MyComponent will have `userId` and `mails` available as props.

Config

Key Type
observe object
resolve object
paginate object
poll object
pendingComponent React Component
errorComponent React Component

More details to follow.

Development

npm install

About

React helpers for Ladda

License:MIT License


Languages

Language:JavaScript 100.0%