parent
28401a26b2
commit
e48de70750
@ -0,0 +1,12 @@ |
|||||||
|
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; |
||||||
|
}; |
@ -1,10 +1,10 @@ |
|||||||
import t from 'tap'; |
import t from 'tap'; |
||||||
import { Marker } from './types'; |
import { Marker } from '../../types'; |
||||||
import { |
import { |
||||||
ReducerAction, |
ReducerAction, |
||||||
createChangeStateMethods, |
createChangeStateMethods, |
||||||
markersReducer, |
markersReducer, |
||||||
} from './useMarkers.js'; |
} from './reducer.js'; |
||||||
|
|
||||||
// Testing entire `useMarkers` custom hook would require us to create test preact components here
|
// Testing entire `useMarkers` custom hook would require us to create test preact components here
|
||||||
// and render them into virtual DOM and check the results, which is just too much hassle
|
// and render them into virtual DOM and check the results, which is just too much hassle
|
Loading…
Reference in new issue