Как стать автором
Обновить

Комментарии 7

Я правильно понимаю, что React подменяет глобальную функцию fetch на свою реализацию, с изменённой семантикой, из-за чего могут сломаться другие библиотеки?

Они манкипатчат fetch. Если мне не изменяет память @artalarзаводил ишью в их репе, мол, не надо так и они её просто закрыли???

FaceBook пробил очередное дно:

React & Next might slow web development due to this stupid action. Monkeypatching it’s always bad. Especially, when you do this for native browsers API. It seems like Facebook hired some freshman’s to develop React. It can’t did a developer that has any experience or can think at least one day ahead. React and Next were my favorite technologies but now I can’t say it anymore. Damn, I really can’t believe that we make this mistake again. Didn’t we have enough problems with such monkeypatching lovers as PrototypeJS? Gosh, I just can’t believe that React team made this mega stupid action. God save the XHR…

По той же ссылке предоставленной @nin-jin, Дэн пишет что by default они ничего не будут патчить. И в исходном коде react 18.2.0, нет ничего связанного с cache.

Кэширование не в React 18, а в next.js: https://nextjs.org/docs/app/building-your-application/data-fetching/caching

Они как бы дают ссылку на RFC, но это не https://github.com/reactjs/rfcs , а форк. Так что или автор перепутал всё что можно, или одно из двух.

Я молчу, что реакт 18.2 (крайняя версия) релизнута год назад.

import { cache } from 'react'

```js

require("react")
{
Children: {
map: [Function: mapChildren],
forEach: [Function: forEachChildren],
count: [Function: countChildren],
toArray: [Function: toArray],
only: [Function: onlyChild]
},
Component: [Function: Component],
Fragment: Symbol(react.fragment),
Profiler: Symbol(react.profiler),
PureComponent: [Function: PureComponent],
StrictMode: Symbol(react.strict_mode),
Suspense: Symbol(react.suspense),
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
ReactCurrentDispatcher: { current: null },
ReactCurrentBatchConfig: { transition: null },
ReactCurrentOwner: { current: null },
ReactDebugCurrentFrame: {
setExtraStackFrame: [Function (anonymous)],
getCurrentStack: null,
getStackAddendum: [Function (anonymous)]
},
ReactCurrentActQueue: {
current: null,
isBatchingLegacy: false,
didScheduleLegacyUpdate: false
}
},
cloneElement: [Function: cloneElementWithValidation],
createContext: [Function: createContext],
createElement: [Function: createElementWithValidation],
createFactory: [Function: createFactoryWithValidation],
createRef: [Function: createRef],
forwardRef: [Function: forwardRef],
isValidElement: [Function: isValidElement],
lazy: [Function: lazy],
memo: [Function: memo],
startTransition: [Function: startTransition],
unstable_act: [Function: act],
useCallback: [Function: useCallback],
useContext: [Function: useContext],
useDebugValue: [Function: useDebugValue],
useDeferredValue: [Function: useDeferredValue],
useEffect: [Function: useEffect],
useId: [Function: useId],
useImperativeHandle: [Function: useImperativeHandle],
useInsertionEffect: [Function: useInsertionEffect],
useLayoutEffect: [Function: useLayoutEffect],
useMemo: [Function: useMemo],
useReducer: [Function: useReducer],
useRef: [Function: useRef],
useState: [Function: useState],
useSyncExternalStore: [Function: useSyncExternalStore],
useTransition: [Function: useTransition],
version: '18.2.0'
}```

Зарегистрируйтесь на Хабре, чтобы оставить комментарий

Публикации

Истории