2.0.11 • Published 16 days ago

taro-hooks v2.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

✨ Features

  • Fully matched Taro
  • Extending common hooks with ahooks
  • Separate abstraction useRequest
  • Complete type tips
  • Extended h5 missing apis

🚀 Quick Start

# npm
$ npm i taro-hooks
# yarn
$ yarn add taro-hooks
# pnpm
$ pnpm add taro-hooks

We use plugins for extending different frameworks. So you need to install the corresponding plugins according to the framework you are currently using

  • React/PReact/Nerv
# npm
$ npm i @taro-hooks/plugin-react
# yarn
$ yarn add @taro-hooks/plugin-react
# pnpm
$ pnpm add @taro-hooks/plugin-react
// config/index.js
module.exports = {
  // ...
  plugins: ['@taro-hooks/plugin-react'],
  // ...
};
  • Vue3
# npm
$ npm i @taro-hooks/plugin-vue
# yarn
$ yarn add @taro-hooks/plugin-vue
# pnpm
$ pnpm add @taro-hooks/plugin-vue
// config/index.js
module.exports = {
  // ...
  plugins: ['@taro-hooks/plugin-vue'],
  // ...
};

⌨️ Usage

  • React/PReact/Nerv
import { useEnv } from 'taro-hooks';

function Index() {
  const env = useEnv();

  return <View>current env: {env}</View>;
}
  • Vue3
<template>
  <view>current env: {{env}}</view>
</template>

<script setup lang="ts">
  import { useEnv } from 'taro-hooks';

  const env = useEnv();
</script>

🎰 auto-import

We provide the @taro-hooks/plugin-auto-import plugin to help you quickly use the unplugin-auto-import capability.

# npm
$ npm i @taro-hooks/plugin-auto-import
# yarn
$ yarn add @taro-hooks/plugin-auto-import
# pnpm
$ pnpm add @taro-hooks/plugin-auto-import
// config/index.js
const config = {
  // ...
  // The main prerequisite is that you have installed the plugin for the corresponding framework.
  plugins: [
    // If you are using vue3, please install the @taro-hooks/plugin-vue plugin beforehand.
    '@taro-hooks/plugin-vue',
    // If using React/PReact/Nerv, please pre-install the @taro-hooks/plugin-react plugin.
    '@taro-hooks/plugin-react',
    // Finally, the auto-import plugin is configured
    [
      '@taro-hooks/plugin-auto-import',
      {
        // your options, see configuration: https://github.com/antfu/unplugin-auto-import#configuration
      }
    ]
  ],
  // ...
};
  • React/PReact/Nerv
function Index() {
  const env = useEnv();

  return <View>current env: {env}</View>;
}
  • Vue3
<template>
  <view>current env: {{env}}</view>
</template>

<script setup lang="ts">
  const env = useEnv();
</script>

📦 Packages

packagesdownloadsversionlicense
taro-hookstaro-hookstaro-hookstaro-hooks
@taro-hooks/ahooks@taro-hooks/ahooks@taro-hooks/ahooks@taro-hooks/ahooks
@taro-hooks/plugin-vue@taro-hooks/plugin-vue@taro-hooks/plugin-vue@taro-hooks/plugin-vue
@taro-hooks/plugin-react@taro-hooks/plugin-react@taro-hooks/plugin-react@taro-hooks/plugin-react
@taro-hooks/use-request@taro-hooks/use-request@taro-hooks/use-request@taro-hooks/use-request
@taro-hooks/plugin-auto-import@taro-hooks/plugin-auto-import@taro-hooks/plugin-auto-import@taro-hooks/plugin-auto-import

🗨️ Communication

🤸 Contribution

See Contributing Guide.

🍻 Contributors

more contributors

📑 License

MIT.

💰 Sponsoring

📈 Star History

Star History Chart

2.0.11

16 days ago

2.0.9

4 months ago

2.0.10

4 months ago

2.0.8

5 months ago

2.0.7

7 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.5

9 months ago

2.0.4

10 months ago

2.0.6

8 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.5.10

1 year ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.6

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.8

3 years ago

1.4.7

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago