@humblejs/data-provider

1.2.6 • Public • Published

DataProvider

Provides JSON data from remote api

Demo

Install

yarn add @humblejs/data-provider

Usage

import createDataProvider from '@humblejs/data-provider';

const { DataProvider, withData } = createDataProvider();

const App = () => (
  <DataProvider url="/api/v1/data">
    <MyComponent />
  </DataProvider>
);
const MyComponent = ({ data }) => (
  <div>My address is {data.ADDRESS}</div>
);

export default withData(MyComponent, [
  'ADDRESS',
]);

Advanced

For JSON Array response

withData(MyComponent, '*')

...

Array.isArray(props.data.items) // == true

For custom key name

withConfig(MyComponent, '*', 'staff')

...

Array.isArray(props.staff.items) // == true

Readme

Keywords

none

Package Sidebar

Install

npm i @humblejs/data-provider

Weekly Downloads

0

Version

1.2.6

License

Apache-2.0

Unpacked Size

9.53 kB

Total Files

10

Last publish

Collaborators

  • abumq
  • firewebkit-devs