Skip to content

Releases: LauraBeatris/use-selected-items-hook

3.1.12

21 Feb 00:31
Compare
Choose a tag to compare

New Major Release

Break Changes

  • Removed generic type for item identifier - It's being accessed with the keyof operator and there's no need to provide it manually #21
  • selectedItems aren't returned with the isSelected state #20
  • Type Definitions Updates (#21)
  • toggleSingleItem action now receives the item as an argument

Improvements

  • Static validation for item identifier (#21)
  • Unit tests (#19)

2.1.10

01 Dec 12:07
00bda27
Compare
Choose a tag to compare

New major release 🎉

But here comes the breaking changes...

New actions

The hook now returns two different actions in order to manipulate the items state:

  • toggleSingleItem
  • toggleAllItems

Update return values

  • selectedItems: The items that are currently selected.
  • items: The items with the status of isSelected.
export interface HookReturnValues<T> {
  items: Item<T>[];
  selectedItems: Item<T>[];
  toggleAllItems: () => void;
  toggleSingleItem: (itemIdentifierValue: any) => void;
}

Initialization

It's possible to initialize the isSelected status of items based on the initialSelectedItems argument.

const noop = () => {};

const fetchItemsFromAPI = () => {..};

const Example = () => {
  const [initialItems, setInitialItems] = useState([]);

  useEffect(() => {
   fetchItemsFromAPI()
    .then(res => setInitialItems(res.data))
    .catch(noop);
  }, []);

  const {
    items,
    selectedItems,
  } = useSelectedItems({
    itemIdentifierKey: "id",
    initialItems: items,
    initialSelectedItems: initialItems.filter(item => item.someRandomCondition);
  });
}

1.1.9

23 Nov 12:17
7a03db7
Compare
Choose a tag to compare

New minor version #9

Bug Fix 🐛

The package was previously being bundled with react, resulting in two different instances of React on the same components tree. #4

Improved workflows and project structure

  1. Now all the configuration related to rollup and babel is being handled by https://github.com/formium/tsdx, which removed a lot of boilerplate in order to configure rollup.

  2. husky and lint-staged are now in the root of the project, instead of being duplicated on the example app folder

  3. Added a better CI workflow which tests the package on multiple environments.

1.0.9

04 Aug 01:18
Compare
Choose a tag to compare

The hook module was being exported in the wrong way and leading to errors when trying to import the definitions of the types of the package.

Now, it should be imported as the following example:

import useSelectedItems from "use-selected-items-hook";
import { Item } from "use-selected-items-hook/build/types";

1.0.8

23 Jul 11:02
Compare
Choose a tag to compare

Misc

New patch release providing access to the definitions of the types of the package

import { Actions, HookArguments, Item, HookReturnValues } from "use-selected-items-hook"  

1.0.7

18 Jul 16:44
97b3712
Compare
Choose a tag to compare

New release proving the capability of fetching items from an API and passing to the hook without having to worry about expections due to falsy values.

Features

📱 Handle items being set asynchronously;

For more details take a look at #2

1.0.5

15 Jul 11:06
Compare
Choose a tag to compare

Misc

  • Updated dependencies and fixed module resolution