vue-hooks-api

Experimental React hooks implementation in Vue3
623 23
Install
npm install vue-hooks-api
Latest Version:0.0.0-beta.5
Vue:3
License:MIT
Last Updated:Jul 17, 2022
Links: GitHub  ·  npm
Maintainer: cobyte

vue-hooks-api

Experimental React hooks implementation in Vue3

install

yarn add vue-hooks-api

React-style Hooks

import { useState, useReducer, useEffect, useLayoutEffect } from "vue-hooks-api";

const FunctionalComponent = (props, context) => {
  const [count1, setCount1] = useState(0);
  const [count2, setCount2] = useReducer((x) => x + 1, 1);
  const [count3, setCount3] = useReducer((x) => x + 1, 2);

  useEffect(() => {
    console.log("useEffect", count2);
  }, [count2]);

  useLayoutEffect(() => {
    console.log("useLayoutEffect", count2);
  }, [count2]);

  return (
    <>
      <button onClick={() => setCount1(2)} {...props}>
        count1:{count1}
      </button>
      <button onClick={() => setCount2()} {...props}>
        count2:{count2}
      </button>
      <button onClick={() => setCount3()} {...props}>
        count3:{count3}
      </button>
    </>
  );
};

export default FunctionalComponent;

Related Packages

kk-vue-hooks

自定义 Vue/React Hooks 集合

1,431
v3-use

Vue3 Hooks library

1,107 4
vue-condition-watcher

Vue composition API for automatic data fetching. With conditions as the core. Ea...

3,951 49
@vue/composition-api

Provide logic composition capabilities for Vue.

6,521,705 4,179
@fect-ui/vue-hooks

Minimalist Vue Compostion Hooks

1,768 330

Version History

Pre-releases (5)
Version Released Vue License
0.0.0-beta.5 ^3.2.23 MIT
0.0.0-beta.4 ^3.2.23 MIT
0.0.0-beta.3 ^3.2.23 MIT
0.0.0-beta.2 ^3.2.23 MIT
0.0.0-beta.1 ^3.2.23 MIT