import { useMemo, useReducer } from 'preact/hooks';
import { createChangeStateMethods, markersReducer } from './reducer';

export const useMarkers = () => {
    const [markers, dispatchMarkers] = useReducer(markersReducer, []);
    const changeStateMethods = useMemo(
        () => createChangeStateMethods(dispatchMarkers),
        [],
    );

    return [markers, changeStateMethods] as const;
};
