echoes/frontend/hooks/useAsyncError.tsx
lsy 5ca72e42cf 前端:创建api,主题,路由服务,重新定义主题插件的约束,错误,加载组件
后端:去除文章和模板的自义定路径,创建获取系统令牌api
2024-11-18 01:09:28 +08:00

15 lines
279 B
TypeScript

// File path: hooks/useAsyncError.tsx
import { useState, useCallback } from 'react';
export function useAsyncError() {
const [, setError] = useState();
return useCallback(
(e: Error) => {
setError(() => {
throw e;
});
},
[setError],
);
}