1.0.12 • Published 4 years ago

use-data-service v1.0.12

Weekly downloads
23
License
MIT
Repository
-
Last release
4 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

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago