How to use the useMemo function from react
Find comprehensive JavaScript react.useMemo code examples handpicked from public code repositorys.
14 15 16 17 18 19 20 21 22 23
const MetaDetails = ({ urlParams, queryParams }) => { const { core } = useServices(); const metaDetails = useMetaDetails(urlParams); const [season, setSeason] = useSeason(urlParams, queryParams); const [tabs, metaExtension, clearMetaExtension] = useMetaExtensionTabs(metaDetails.metaExtensions); const [metaPath, streamPath] = React.useMemo(() => { return metaDetails.selected !== null ? [metaDetails.selected.metaPath, metaDetails.selected.streamPath] : [null, null];
129
501
31
+ 3 other calls in file
GitHub: nklhtv/stremio-web
17 18 19 20 21 22 23 24 25 26
const useSettings = require('./useSettings'); const styles = require('./styles'); const Player = ({ urlParams, queryParams }) => { const { chromecast, shell } = useServices(); const [forceTranscoding, maxAudioChannels] = React.useMemo(() => { return [ queryParams.has('forceTranscoding'), queryParams.has('maxAudioChannels') ? parseInt(queryParams.get('maxAudioChannels'), 10) : null ];
129
1
0
GitHub: jlvcm/stremio-web
37 38 39 40 41 42 43 44 45 46
if (metaItem !== selectedMetaItem) { event.preventDefault(); event.currentTarget.focus(); } }, [discover.catalog_resource, selectedMetaItem]); const available = React.useMemo(() => { return discover.selectable.types.length > 0 || discover.catalog_resource !== null; }, [discover]); React.useLayoutEffect(() => { const metaItem = getMetaItemAtIndex(discover.catalog_resource, 0);
129
0
1
GitHub: szhsin/react-menu
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736
block: menuClass, element: menuItemClass, modifiers: modifiers, className: itemClassName }), children: react.useMemo(function () { return safeCall(label, modifiers); }, [label, modifiers]) })), state && getMenuList()] });
48
881
6
+ 17 other calls in file
GitHub: szhsin/react-accordion
231 232 233 234 235 236 237 238 239 240 241
function setRef(ref, instance) { typeof ref === 'function' ? ref(instance) : ref.current = instance; } function useMergeRef(refA, refB) { return react.useMemo(() => { if (!refA) return refB; if (!refB) return refA; return instance => { setRef(refA, instance);
4
84
0
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
} } }); return _arr; }, [refreshKey]); var selectState = React.useMemo(function () { if (selectReducerKey && selectReducerKey.length) { var _arr = []; selectReducerKey.forEach(function (_k) { return _arr.push(function (state) {
6
9
3
+ 7 other calls in file
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247
const setValue = (newValue) => { if (isMounted()) { _setValue(newValue); } }; React.useMemo(() => { if (exists2) { remaining({ ...identity, instance,
1
54
1
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450
}; var makeHeaderRender = function (label, render) { return render ? function () { return render({ label: label }); } : function () { return label; }; }; var useTable = function (columns, data, options) { var columnsWithSorting = React.useMemo(function () { return columns.map(function (column) { return __assign(__assign({}, column), { label: column.label ? column.label : column.name, hidden: column.hidden ? column.hidden : false, sort: column.sort, sorted: { on: false, asc: false,
1
1
0
+ 7 other calls in file
23 24 25 26 27 28 29 30 31 32
// eslint-disable-next-line react-hooks/exhaustive-deps var handleSearch = react_2.useCallback(throttle_debounce_1.debounce(200, false, function (e) { var query = e.target.value; setSearchQuery(query); }), []); var activeToken = react_2.useMemo(function () { return tokens.find(function (token) { return token.address === activeAddress; }); }, [tokens, activeAddress]); var displayTokens = react_2.useMemo(function () { var query = searchQuery.toLowerCase(); return __spreadArrays([ activeToken
0
0
1
+ 5 other calls in file
195 196 197 198 199 200 201 202 203 204
var breakpointList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var _useState = React.useState(), _useState2 = _slicedToArray(_useState, 2), currentBreakpointSetting = _useState2[0], setCurrentBreakpointSetting = _useState2[1]; var random = React.useMemo(function () { return "".concat(Math.random(), "-").concat(Math.random()); }, []); var sortedBreakpointList = React.useMemo(function () { return _toConsumableArray(breakpointList).sort(function (a, b) {
0
0
0
+ 4 other calls in file
GitHub: daneg69/quizmeapp
10 11 12 13 14 15 16 17 18 19
return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = require("react"); function useLocalStorage(key, defaultValue, options) { var opts = react_1.useMemo(function () { return __assign({ serializer: JSON.stringify, parser: JSON.parse, logger: console.log, syncData: true }, options); }, [options]); var serializer = opts.serializer, parser = opts.parser, logger = opts.logger, syncData = opts.syncData; var _a = react_1.useState(function () {
0
0
0
224 225 226 227 228 229 230 231 232 233 234
return props.inherit !== false ? context : {}; } function useCreateMotionContext(props) { const { initial, animate } = getCurrentTreeVariants(props, React.useContext(MotionContext)); return React.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]); } function variantLabelsAsDependency(prop) { return Array.isArray(prop) ? prop.join(" ") : prop; }
0
0
1
+ 5 other calls in file
73 74 75 76 77 78 79 80 81 82 83
function RuntimeErrors({ errors, dismiss }) { const deduplicatedErrors = React.useMemo(() => { const errorCache = new Set(); const errorList = []; errors.forEach(error => { // Second line contains the exact location
0
0
0
64 65 66 67 68 69 70 71 72 73 74
function GraphqlErrors({ errors, dismiss }) { const deduplicatedErrors = React.useMemo(() => Array.from(new Set(errors)), [errors]); const hasMultipleErrors = deduplicatedErrors.length > 1; return /*#__PURE__*/React.createElement(_overlay.Overlay, null, /*#__PURE__*/React.createElement(_overlay.Header, { "data-gatsby-error-type": "graphql-error" }, /*#__PURE__*/React.createElement("div", {
0
0
0
GitHub: DK-Dinesh-DK/AgGrid
556 557 558 559 560 561 562 563 564 565
const { columns, colSpanColumns, lastFrozenColumnIndex, groupBy } = react.useMemo(() => { const groupBy = []; let lastFrozenColumnIndex = -1; const columns = rawColumns?.map(rawColumn => { const rowGroup = rawGroupBy?.includes(rawColumn.field) ?? false;
0
0
1
+ 23 other calls in file
GitHub: teu-ai/ant-design
97 98 99 100 101 102 103 104 105 106
} }, }; }; }, []); var fns = React.useMemo(function () { return { info: getConfirmFunc(_confirm.withInfo), success: getConfirmFunc(_confirm.withSuccess), error: getConfirmFunc(_confirm.withError),
0
0
2
GitHub: blueo/Recoil
235 236 237 238 239 240 241 242 243 244
}); return () => currentSubscriptions.forEach((_, key) => unsubscribeFrom(key)); }, [componentName, storeRef, unsubscribeFrom, updateState]); return useMemo(() => { // eslint-disable-next-line no-shadow function useSetRecoilState<T>( recoilState: RecoilState<T>, ): SetterOrUpdater<T> {
0
0
0
GitHub: siefkenj/reakit-react-18
83 84 85 86 87 88 89 90 91 92
var onFocus = React.useCallback(function (event) { if (!id || !event.currentTarget.contains(event.target)) return; // this is already focused, so we move silently options.move(id, true); }, [options.move, id]); var onKeyDown = React.useMemo(function () { return createOnKeyDown.createOnKeyDown({ onKeyDown: htmlOnKeyDown, stopPropagation: true, shouldKeyDown: function shouldKeyDown(event) {
0
0
1
+ 5 other calls in file
react.default is the most popular function in react (505 examples)