Skip to content

Commit

Permalink
docs: update package name and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kalu5 committed Apr 13, 2024
1 parent 1530d55 commit b84050e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kalu5/vue_hooks",
"name": "@kalu5/vue3-hooks",
"type": "module",
"version": "1.0.8",
"version": "1.0.9",
"private": false,
"description": "This is vue3 hooks utils",
"author": "lujialong",
Expand Down
23 changes: 17 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@
</h1>

<p>
This is vue3 hooks utils . You can use it just like react .
This is vue3 hooks utils , You can use it just like react .
</p>

**Advantage:**

1. Semantics is better.
2. Logic is clearer.

I highly recommend using it.

# Use

``` bash
pnpm i @kalu5/vue_hooks
pnpm i @kalu5/vue3-hooks
```

## useState

The correct way to open State.

eg:
``` vue
<script setup lang="ts">
import { useState } from '@kalu5/vue_hooks'
const [state, setState] = useState(0)
import { useState } from '@kalu5/vue3-hooks'
const [state, setState] = useState<number>(0)
</script>
<template>
Expand All @@ -37,17 +46,19 @@ const [state, setState] = useState(0)
eg:
``` vue
<script setup lang="ts">
import { useReducer } from '@kalu5/vue_hooks'
import { useReducer } from '@kalu5/vue3-hooks'
function reducer(state, action) {
if (action.type === 'add')
return state.value + 1
return state.value - 1
}
const [state, dispatch] = useReducer(reducer, 1)
const [state, dispatch] = useReducer<number>(reducer, 1)
const [newState, newDispatch] = useReducer<number>(reducer, 2, (init: number) => init * 3)
</script>
<template>
<h1>{{ state }}</h1>
<h2>{{ newState }}</h2>
<button @click="dispatch({ type: 'add' })">
Add
</button>
Expand Down

0 comments on commit b84050e

Please sign in to comment.