The purpose of this project is to bring you basic data structures through React hooks.
Use the package manager npm to install react-hooks-data-structures
.
npm i react-hooks-data-structures
import { useLinkedList } from 'react-hooks-data-structures/LinkedList';
const SomeComponent = (props) => {
const linkedList = useLinkedList();
const handleClick = useCallback((evt) => {
linkedList.add(evt.target.value);
}, []);
return (
<>
{linkedList.map((value, idx) => <Item key={idx}>{value}</Item>)}
</>
)
}