@airplane/views
Version:
A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.
28 lines (27 loc) • 792 B
JavaScript
import { useReducer, useCallback, useMemo } from "react";
import { ComponentType, useSyncComponentState } from "../../context/context.js";
import { reducer } from "./reducer.js";
const useTabsState = (id, options) => {
var _a;
const [internalState, dispatch] = useReducer(reducer, {
value: (_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.value
});
const setValue = useCallback((value) => {
dispatch({
type: "setValue",
value
});
}, []);
const state = useMemo(() => ({
id,
setValue,
value: internalState.value,
componentType: ComponentType.Tabs
}), [id, internalState.value, setValue]);
useSyncComponentState(id, state);
return state;
};
export {
useTabsState
};
//# sourceMappingURL=useTabsState.js.map