Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmoeschinger committed Aug 3, 2022
1 parent 2bc5aa3 commit a226566
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moment-hooks",
"version": "1.2.1",
"version": "2.0.0",
"description": "Incredibly awesome hooks",
"keywords": [
"react",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/useArrayV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ describe('useArray', () => {
result.current.toggle('1');
});

expect(result.current.value).toEqual(["1"]);
expect(result.current.value).toEqual(['1']);
});
});
7 changes: 5 additions & 2 deletions src/useArrayV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import React from 'react';
const defaultFinder = <T>(list: T[], item: T) =>
list.findIndex((listItem) => listItem === item);

const useArrayV2 = <T = any>(defaultValue: T[] = [], finder = defaultFinder) => {
const useArrayV2 = <T = any>(
defaultValue: T[] = [],
finder = defaultFinder
) => {
const [value, setValue] = React.useState(defaultValue);

const has = React.useCallback(
Expand Down Expand Up @@ -52,4 +55,4 @@ const useArrayV2 = <T = any>(defaultValue: T[] = [], finder = defaultFinder) =>
);
};

export default useArrayV2;
export default useArrayV2;

0 comments on commit a226566

Please # to comment.