Skip to content

Commit

Permalink
feat(docs): include insertMany function
Browse files Browse the repository at this point in the history
  • Loading branch information
Suzan-Dev committed Sep 28, 2022
1 parent fc33a56 commit cfdc2aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ pnpm add react-complex-state
Pass the state you want to use in `useComplexState` hook like you do in `useState`.

```jsx
import useComplexState from "react-complex-state";
import { useComplexState } from "react-complex-state";

function App() {
const complexState = useComplexState(["John", "William"]);
Expand All @@ -53,13 +53,14 @@ function App() {
export default App;
```

### Returns
## Returns

| return | type | description |
| ------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value | array | The data of your state. |
| setValue | function | The usual setState function. Use it if you want control over your state. |
| insert | function | `(data: T, index?: number) => void` <br /> Add data to your state at an index. By default it will add the data at the end. |
| insertMany | function | `(data: T[], index?: number) => void` <br /> Add array of data to your state at an index. Defaults are similar to insert function. |
| update | function | `(data: T, index: number) => void` <br /> Update your state data at an index. |
| partialUpdate | function | `(data: Partial<T>, index: number) => void` <br /> Update only the data that you passed at an index. Other remaining data will be unchanged. (Only usable when your state contains array of objects) |
| remove | function | `(index: number) => void` <br /> Delete your state data at an index. |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-complex-state",
"version": "1.0.1",
"description": "A complex local state made easy in react",
"description": "A custom hook that makes it easy when working with complex state in react.",
"author": "Suzan-Dev",
"license": "MIT",
"main": "./lib/cjs/index.js",
Expand Down

0 comments on commit cfdc2aa

Please sign in to comment.