Comments (1)
import React, { useCallback } from "react";
import { View, Text, Button, Image } from "@tarojs/components";
import { useEnv, useNavigationBar, useModal, useToast, useRequestSubscribeMessage } from "taro-hooks";
import logo from "./hook.png";
import './index.less'
const Index = () => {
const env = useEnv();
const [requestSubscribeMessage] = useRequestSubscribeMessage();
const [_, { setTitle }] = useNavigationBar({ title: "Taro Hooks" });
const [show] = useModal({
title: "Taro Hooks!",
showCancel: false,
confirmColor: "#8c2de9",
confirmText: "支持一下",
mask: true,
});
const [showToast] = useToast({ mask: true });
const handleModal = useCallback(() => {
show({ content: "不如给一个star⭐️!" }).then(() => {
showToast({ title: "点击了支持!" });
});
}, [show, showToast]);
const handleRequestSubscribeMessage = useCallback(async () => {
let content = '订阅成功!';
const subscribeId = 'jeNEwprDztjgwq0BI1raBmcJ7Sw1ldt-8lRi-7jXeyY';
try {
const { [subscribeId]: result } = await requestSubscribeMessage([
subscribeId,
]);
if (result !== 'accept') {
content = '订阅失败';
}
} catch (e) {
content = '订阅失败';
}
show({ content });
}, [requestSubscribeMessage, show]);
return (
<View className="wrapper">
<Image className="logo" src={logo} />
<Text className="title">为Taro而设计的Hooks Library</Text>
<Text className="desc">
目前覆盖70%官方API. 抹平部分API在H5端短板. 提供近40+Hooks!
并结合ahook适配Taro!
</Text>
<View className="list">
<Text className="label">运行环境</Text>
<Text className="note">{env}</Text>
</View>
<Button className="button" onClick={handleRequestSubscribeMessage}>订阅</Button>
<Button className="button" onClick={() => setTitle("Taro Hooks Nice!")}>
设置标题
</Button>
<Button className="button" onClick={handleModal}>
使用Modal
</Button>
</View>
);
};
export default Index;
from taro-hooks.
Related Issues (20)
- bug:useRequest 设置 cachekey 以后列表数据残留 HOT 3
- taro-cli创建项目时选择taro-hooks@canary模板,在微信开发者工具控制台报错,渲染失败 HOT 7
- 现有taro项目中引入taro-hooks,在微信小程序开发者工具中报错 HOT 7
- bug: useRequest 未触底 连续执行loadmore HOT 3
- bug: plugin 中使用 @taro-hooks/shared 导致报错 HOT 4
- bug: 2.0版本useRequest类型定义有问题 HOT 3
- 安装taro-hooks后 ts报错“View”不能用作 JSX 组件。 HOT 3
- 官网taro init 的taro hooks模板项目启动报错。 HOT 20
- feat: preact支持 HOT 7
- bug: taro-hooks 的依赖是否遗漏了@taro-hooks/core HOT 5
- bug: error Unable to resolve module @taro-hooks/core from /Users/orrin/Workspaces/项目/sass_crm_rn/node_modules/taro-hooks/lib/useRouter/index.js: @taro-hooks/core could not be found within the project or in these directories: HOT 1
- bug: 微信小程序无法运行 HOT 3
- feat: 支持unplugin-auto-import HOT 5
- bug: 在app.ts里面使用时会报错 HOT 2
- bug: No matching export in "node_modules/@tarojs/taro-h5/dist/index.js" for import "requestSubscribeDeviceMessage" HOT 3
- bug: Cannot find module '@taro-hooks/core' HOT 3
- 为什么next-version-taro-hooks.vercel.app 这个网址最近都无法访问,只能通过vpn访问 HOT 4
- bug: taro-hooks2.0 不支持rn HOT 19
- 使用痛点 建议添加或修改 HOT 5
- bug: AutoImport 引入,在vscode里面看不到函数的方法 HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from taro-hooks.