1import { useCallback, useState } from 'react';
4 * Manages an immutable array of items.
6export default function useArray(initialItems = [], itemBuilder) {
7 const [items, _setItems] = useState(initialItems);
9 const append = useCallback(
10 () => _setItems(items => [...items, itemBuilder()]),
11 [_setItems, itemBuilder]
14 const removeAt = useCallback(
17 const newItems = [...items.slice(0, i), ...items.slice(i + 1)];
23 const updateAt = useCallback(
31 ...items.slice(i + 1),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list