Skip to content

herrherrmann/ladda-react

 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%