@dlkit/utils
v0.0.7
Published
得力e+ 常用工具类
Downloads
10
Readme
@dlkit/utils
得力e+ 常用工具类集合
axios
axios 的封装,支持 web、小程序
import axios from '@dlkit/utils/axios';
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone',
},
});
sentry-mini
用于小程序平台的 sentry
import { init } from '@dlkit/utils/sentry-mini';
init({
dsn: '__DSN__',
});
zustand
import { defineStore } from '@dlkit/utils/zustand';
interface ICounter {
count: number;
increase: () => void;
}
const useCounter = defineStore<ICounter>(set => ({
count: 1,
increase() {
set(state => {
state.count += 1;
});
},
}));
const Counter = () => {
const { count, increase } = useCounter();
return (
<div>
<div>{count}</div>
<button onClick={increase}>increase</button>
</div>
);
};
// 在 react 组件外使用
const store = useCounter.getState();
store.setState({
count: store.count + 1,
});