1.0.12 • Published 5 years ago

use-data-service v1.0.12

Weekly downloads
23
License
MIT
Repository
-
Last release
5 years ago

INSTALL

npm install use-data-service

HOW TO USE

import useDataService from 'use-data-service';

// example: get data from axios / fetch / AsyncStorage (react-native) ...
async function getDetail({ id }) {
  return {
    success: false,
    data: {
      id: 1,
      title: 'foo',
      content: 'bar'
    }
  };
}

// postId from location.query.id / deeplink ...
function ListUI({ postId }) {
  const [loading, data, error] = useDataService(getDetail, { id: postId});

  if (loading) {
    return <Spin />
  }

  return (
    <Detail>
      <Title>{data.title}</Title>
      <Content>{data.content}</Content>
    </Detail>
  )
}
1.0.11

5 years ago

1.0.10

5 years ago

1.0.12

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago