mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
20 lines
658 B
React
20 lines
658 B
React
import { createContext, useContext } from 'react';
|
|
import { useDriveControls as useDriveControlsHook } from '../hooks/useDriveControls.js';
|
|
|
|
/* eslint-disable react-refresh/only-export-components */
|
|
|
|
const DriveControlContext = createContext(null);
|
|
|
|
export function DriveControlProvider({ children }) {
|
|
const controls = useDriveControlsHook();
|
|
return <DriveControlContext.Provider value={controls}>{children}</DriveControlContext.Provider>;
|
|
}
|
|
|
|
export function useDriveControl() {
|
|
const context = useContext(DriveControlContext);
|
|
if (!context) {
|
|
throw new Error('useDriveControl must be used within DriveControlProvider');
|
|
}
|
|
return context;
|
|
}
|