How to use the useContext function from react
Find comprehensive JavaScript react.useContext code examples handpicked from public code repositorys.
GitHub: dbeaver/cloudbeaver
111 112 113 114 115 116 117 118 119 120
} const DataGridDefaultComponentsContext = /*#__PURE__*/react.createContext(undefined); const DataGridDefaultComponentsProvider = DataGridDefaultComponentsContext.Provider; function useDefaultComponents() { return react.useContext(DataGridDefaultComponentsContext); } function SelectCellFormatter({ value,
267
0
43
+ 5 other calls in file
GitHub: szhsin/react-menu
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768
restProps = _objectWithoutPropertiesLoose(_ref, _excluded$5); var isDisabled = !!disabled; var _useItemState = useItemState(itemRef, itemRef, isHovering, isDisabled), setHover = _useItemState.setHover, restStateProps = _objectWithoutPropertiesLoose(_useItemState, _excluded2$1); var eventHandlers = react.useContext(EventHandlersContext); var radioGroup = react.useContext(RadioGroupContext); var isRadio = type === 'radio'; var isCheckBox = type === 'checkbox'; var isAnchor = !!href && !isDisabled && !isRadio && !isCheckBox;
48
881
6
+ 12 other calls in file
GitHub: szhsin/react-accordion
256 257 258 259 260 261 262 263 264 265
isEnter: _initialEntered, isResolved: true }; }; const useAccordionContext = () => { const context = react.useContext(AccordionContext); if (process.env.NODE_ENV !== 'production' && !context.stateMap) { throw new Error('[React-Accordion] Cannot find a <AccordionProvider/> above this AccordionItem.'); } return context;
4
84
0
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039
var ID_KEY = 'id'; var hook = (function () { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var _ref = React.useContext(FormContext) || {}, _ref$inputProps = _ref.inputProps, inputProps = _ref$inputProps === void 0 ? {} : _ref$inputProps, idKey = _ref.idKey, onSubmit = _ref.onSubmit;
6
9
3
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838
}; var templateObject_1$w; var useModal = function (modal, closeOnOverlayClick) { if (closeOnOverlayClick === void 0) { closeOnOverlayClick = true; } var _a = React.useContext(Context), onPresent = _a.onPresent, onDismiss = _a.onDismiss, setCloseOnOverlayClick = _a.setCloseOnOverlayClick; var onPresentCallback = React.useCallback(function () { onPresent(modal); }, [modal, onPresent]); React.useEffect(function () {
1
1
0
GitHub: Flandre3569/vigor.js
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
const rootElement = useRoutes(routes); return rootElement; }; const contextData = React.createContext({}); const useContextData = () => { return React.useContext(contextData); }; const base = ""; const vars = ""; const __uno = "";
0
1
1
18 19 20 21 22 23 24 25 26 27
}); }, []); return <AuthContext.Provider value={value} {...props}></AuthContext.Provider>; } function useAuth() { const context = useContext(AuthContext); if (typeof context === "undefined") throw new Error("useAuth must be used within AuthProvider"); return context; }
0
0
1
20 21 22 23 24 25 26 27 28 29
beforeEach(() => { jest.resetModules(); ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false; React = require('react'); useContext = React.useContext; ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); gen = require('random-seed'); });
0
0
0
12 13 14 15 16 17 18
{children} </ChatLayoutContext.Provider> ) } export const useChatLayout = () => useContext(ChatLayoutContext)
0
0
0
85 86 87 88 89 90 91 92 93 94 95 96
reducedMotion: "never", }); const MotionContext = React.createContext({}); function useVisualElementContext() { return React.useContext(MotionContext).visualElement; } /** * @public
0
0
1
+ 14 other calls in file
GitHub: DK-Dinesh-DK/AgGrid
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
isCellSelected, column, children, alterHeaderName }) { const filters = react.useContext(FilterContext$1); const { ref, tabIndex } = useFocusRef(isCellSelected);
0
0
1
+ 7 other calls in file
5 6 7 8 9 10 11 12 13 14 15 16
const CartContext = createContext({}) export function CartContextProvider({ children }) { const [cart, setCart] = useState([]) // console.log('cart', cart) const { user } = useContext(AuthContext) useEffect(() => { axiosClient.get('/cart').then((rs) => setCart(rs.data.data.cart)) }, [user])
0
0
0
30 31 32 33 34 35 36 37 38 39
onHideUnderlay, item, toggleBookmark, handlePress, }) => { const theme = React.useContext(RNTesterThemeContext); const platform = item.module.platform; const onIos = !platform || platform === 'ios'; const onAndroid = !platform || platform === 'android'; const rightAddOn = (
0
0
0
react.default is the most popular function in react (505 examples)