ra-core
Version:
Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React
11 lines • 658 B
JavaScript
import { useStore } from "../store/useStore.js";
import { usePreferenceKey } from "./PreferenceKeyContext.js";
function usePreference(key = '', defaultValue = undefined) {
const preferenceKey = usePreferenceKey();
if (!preferenceKey) {
throw new Error("usePreference cannot be used outside of a Configurable component. Did you forget to wrap your component with <Configurable>? If you don't want to use Configurable, you can use the useStore hook instead.");
}
return useStore(preferenceKey && key ? `${preferenceKey}.${key}` : preferenceKey ?? key, defaultValue);
}
export { usePreference };
//# sourceMappingURL=usePreference.js.map