code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function PrunedNonReactive() { const obj = makeObject(); useIdentity(null); mutate(obj); useEffect(() => print(obj.value)); }
When a semantically non-reactive value has a pruned scope (i.e. the object identity becomes reactive, but the underlying value it represents should be constant), the compiler can choose to either - add it as a dependency (and rerun the effect) - not add it as a dependency We keep semantically non-reactive values in bo...
PrunedNonReactive
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/pruned-nonreactive-obj.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/pruned-nonreactive-obj.js
MIT
function Component({foo}) { function f() { console.log(foo); } // No inferred dep array, the argument is not a lambda useEffect(f); }
Error on non-inlined effect functions: 1. From the effect hook callee's perspective, it only makes sense to either (a) never hard error (i.e. failing to infer deps is acceptable) or (b) always hard error, regardless of whether the callback function is an inline fn. 2. (Technical detail) it's harder to suppo...
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.non-inlined-effect-fn.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.non-inlined-effect-fn.js
MIT
function Component({foo}) { 'use memo if(getTrue)'; const arr = []; useEffectWrapper(() => arr.push(foo)); arr.push(2); return arr; }
TODO: run the non-forget enabled version through the effect inference pipeline.
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.todo-dynamic-gating.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.todo-dynamic-gating.js
MIT
function Component({foo}) { const arr = []; useEffectWrapper(() => arr.push(foo)); arr.push(2); return arr; }
TODO: run the non-forget enabled version through the effect inference pipeline.
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.todo-gating.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/error.todo-gating.js
MIT
function useFoo({arr1, arr2}) { const cb1 = e => arr1[0].value + e.value; const getArrMap1 = () => arr1.map(cb1); const cb2 = e => arr2[0].value + e.value; const getArrMap2 = () => arr1.map(cb2); return ( <Stringify getArrMap1={getArrMap1} getArrMap2={getArrMap2} shouldInvokeFns={true} ...
Forked from array-map-simple.js Named lambdas (e.g. cb1) may be defined in the top scope of a function and used in a different lambda (getArrMap1). Here, we should try to determine if cb1 is actually called. In this case: - getArrMap1 is assumed to be called as it's passed to JSX - cb1 is not assumed to be called sin...
useFoo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-callback-cross-context.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-callback-cross-context.js
MIT
function useFoo({arr1, arr2}) { const cb1 = e => arr1[0].value + e.value; const x = arr1.map(cb1); const cb2 = e => arr2[0].value + e.value; const y = arr1.map(cb2); return [x, y]; }
Forked from array-map-simple.js Whether lambdas are named or passed inline shouldn't affect whether we expect it to be called.
useFoo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-callback.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-callback.js
MIT
function useFoo({arr1, arr2}) { const getVal1 = () => arr1[0].value; const cb1 = e => getVal1() + e.value; const x = arr1.map(cb1); const getVal2 = () => arr2[0].value; const cb2 = e => getVal2() + e.value; const y = arr1.map(cb2); return [x, y]; }
Forked from array-map-simple.js Here, getVal1 has a known callsite in `cb1`, but `cb1` isn't known to be called (it's only passed to array.map). In this case, we should be conservative and assume that all named lambdas are conditionally called.
useFoo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-chained-callbacks.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-named-chained-callbacks.js
MIT
function useFoo({arr1, arr2}) { const x = arr1.map(e => arr1[0].value + e.value); const y = arr1.map(e => arr2[0].value + e.value); return [x, y]; }
Test that we're not hoisting property reads from lambdas that are created to pass to opaque functions, which often have maybe-invoke semantics. In this example, we shouldn't hoist `arr[0].value` out of the lambda. ```js e => arr[0].value + e.value <-- created to pass to map arr.map(<cb>) <-- argument o...
useFoo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-simple.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/array-map-simple.js
MIT
function useMakeCallback({arr}) { return { getElement0: () => arr[0].value, getElement1: () => arr[1].value, }; }
Assume that only directly returned functions or JSX attributes are invoked. Conservatively estimate that functions wrapped in objects or other containers might never be called (and therefore their property loads are not hoistable).
useMakeCallback
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/return-object-of-functions.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-function/nullable-objects/return-object-of-functions.js
MIT
function ComponentC(props) { const a = []; a.push(props.a); if (props.b) { a.push(props.c); return null; } a.push(props.d); return a; }
props.b *does* influence `a`, but only in a way that is never observable
ComponentC
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/conditional-early-return.js
MIT
function Component({cond, a}) { let contextVar; if (cond) { contextVar = {val: a}; } else { contextVar = {}; throwErrorWithMessage(''); } const cb = {cb: () => contextVar.val * 4}; /** * manually specify input to avoid adding a `PropertyLoad` from contextVar, * which might affect hoistabl...
Context variables are local variables that (1) have at least one reassignment and (2) are captured into a function expression. These have a known mutable range: from first declaration / assignment to the last direct or aliased, mutable reference. This fixture validates that forget can take granular dependencies on con...
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/context-var-granular-dep.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/context-var-granular-dep.js
MIT
function Component(props) { const foo = props => { console.log(props); }; if (props.cond) { useEffect(() => { fire(foo(props)); }); } return <Stringify />; }
When @enableFire is specified, retry compilation with validation passes (e.g. hook usage) disabled
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-validate-conditional-hook.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-validate-conditional-hook.js
MIT
function Component({props, bar}) { 'use no memo'; const foo = () => { console.log(props); }; useEffect(() => { fire(foo(props)); fire(foo()); fire(bar()); }); return null; }
TODO: we should eventually distinguish between `use no memo` and `use no compiler` directives. The former should be used to *only* disable memoization features.
Component
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/error.use-no-memo.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/error.use-no-memo.js
MIT
function useFoo({cond}) { const ref = useRef(); const derived = cond ? ref.current : makeObject(); useSpecialEffect(() => { log(derived); }, [derived]); return ref; }
The retry pipeline disables memoization features, which means we need to provide an alternate implementation of effect dependencies which does not rely on memoization.
useFoo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/infer-deps-on-retry.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/infer-deps-on-retry.js
MIT
function NonFireComponent({prop1}) { /** * This component bails out but does not use fire */ const foo = () => { try { console.log(prop1); } finally { console.log('jbrown215'); } }; useEffect(() => { foo(); }); }
Compilation of this file should succeed.
NonFireComponent
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
MIT
foo = () => { try { console.log(prop1); } finally { console.log('jbrown215'); } }
This component bails out but does not use fire
foo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
MIT
foo = () => { try { console.log(prop1); } finally { console.log('jbrown215'); } }
This component bails out but does not use fire
foo
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
MIT
function FireComponent(props) { /** * This component uses fire and compiles successfully */ const foo = props => { console.log(props); }; useEffect(() => { fire(foo(props)); }); return null; }
This component bails out but does not use fire
FireComponent
javascript
facebook/react
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
https://github.com/facebook/react/blob/master/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/bailout-retry/no-fire-todo-syntax-shouldnt-throw.js
MIT
componentDidMount() { this._interval = window.setInterval(this.onTick, 20); }
When the component is mounted into the document - this is similar to a constructor, but invoked when the instance is actually mounted into the document. Here, we'll just set up an animation loop that invokes our method. Binding of `this.onTick` is not needed because all React methods are automatically bound before bein...
componentDidMount
javascript
facebook/react
fixtures/art/VectorWidget.js
https://github.com/facebook/react/blob/master/fixtures/art/VectorWidget.js
MIT
render() { return ( <Surface width={700} height={700} style={{cursor: 'pointer'}}> {this.renderGraphic(this.state.degrees)} </Surface> ); }
This is the "main" method for any component. The React API allows you to describe the structure of your UI component at *any* point in time.
render
javascript
facebook/react
fixtures/art/VectorWidget.js
https://github.com/facebook/react/blob/master/fixtures/art/VectorWidget.js
MIT
async function renderToString(serverRenderer, element) { let didError = false; const stream = await serverRenderer.renderToReadableStream(element, { onError(error) { didError = true; console.error(error); }, }); await stream.allReady; if (didError) { throw new Error('The above error o...
@param {import('react-dom/server')} serverRenderer
renderToString
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
onError(error) { didError = true; console.error(error); }
@param {import('react-dom/server')} serverRenderer
onError
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
async function getRenderedAttributeValue( react, renderer, serverRenderer, attribute, type ) { const originalConsoleError = console.error; console.error = warn; const containerTagName = attribute.containerTagName || 'div'; const tagName = attribute.tagName || 'div'; function createContainer() { ...
@param {import('react-dom/server')} serverRenderer
getRenderedAttributeValue
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function createContainer() { if (containerTagName === 'svg') { return document.createElementNS('http://www.w3.org/2000/svg', 'svg'); } else if (containerTagName === 'document') { return document.implementation.createHTMLDocument(''); } else if (containerTagName === 'head') { return documen...
@param {import('react-dom/server')} serverRenderer
createContainer
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
async function prepareState(initGlobals) { async function getRenderedAttributeValues(attribute, type) { const { ReactStable, ReactDOMStable, ReactDOMServerStable, ReactNext, ReactDOMNext, ReactDOMServerNext, } = initGlobals(attribute, type); const reactStableValue = awa...
@param {import('react-dom/server')} serverRenderer
prepareState
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
async function getRenderedAttributeValues(attribute, type) { const { ReactStable, ReactDOMStable, ReactDOMServerStable, ReactNext, ReactDOMNext, ReactDOMServerNext, } = initGlobals(attribute, type); const reactStableValue = await getRenderedAttributeValue( ReactStab...
@param {import('react-dom/server')} serverRenderer
getRenderedAttributeValues
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function RendererResult({ result, canonicalResult, defaultValue, canonicalDefaultValue, didWarn, didError, ssrHasSameBehavior, ssrHasSameBehaviorExceptWarnings, }) { let backgroundColor; if (didError) { backgroundColor = errorColor; } else if (didWarn) { backgroundColor = warnColor; } el...
@param {import('react-dom/server')} serverRenderer
RendererResult
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function ResultPopover(props) { return ( <pre css={{ padding: '1em', minWidth: '25em', }}> {JSON.stringify( { reactStable: props.reactStable, reactNext: props.reactNext, hasSameBehavior: props.hasSameBehavior, }, null, ...
@param {import('react-dom/server')} serverRenderer
ResultPopover
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
componentWillUnmount() { if (this.timeout) { clearTimeout(this.interval); } }
@param {import('react-dom/server')} serverRenderer
componentWillUnmount
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
render() { const {reactStable, reactNext, hasSameBehavior} = this.props; const style = { position: 'absolute', width: '100%', height: '100%', }; let highlight = null; let popover = null; if (this.state.showInfo) { highlight = ( <div css={{ p...
@param {import('react-dom/server')} serverRenderer
render
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function ColumnHeader({children}) { return ( <div css={{ position: 'absolute', width: '100%', height: '100%', display: 'flex', alignItems: 'center', }}> {children} </div> ); }
@param {import('react-dom/server')} serverRenderer
ColumnHeader
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function RowHeader({children, checked, onChange}) { return ( <div css={{ position: 'absolute', width: '100%', height: '100%', display: 'flex', alignItems: 'center', }}> <input type="checkbox" checked={checked} onChange={onChange} /> {children} </...
@param {import('react-dom/server')} serverRenderer
RowHeader
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function CellContent(props) { const { columnIndex, rowIndex, attributesInSortedOrder, completedHashes, toggleAttribute, table, } = props; const attribute = attributesInSortedOrder[rowIndex - 1]; const type = types[columnIndex - 1]; if (columnIndex === 0) { if (rowIndex === 0) { ...
@param {import('react-dom/server')} serverRenderer
CellContent
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function saveToLocalStorage(completedHashes) { const str = JSON.stringify([...completedHashes]); localStorage.setItem('completedHashes', str); }
@param {import('react-dom/server')} serverRenderer
saveToLocalStorage
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function restoreFromLocalStorage() { const str = localStorage.getItem('completedHashes'); if (str) { const completedHashes = new Set(JSON.parse(str)); return completedHashes; } return new Set(); }
@param {import('react-dom/server')} serverRenderer
restoreFromLocalStorage
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
async componentDidMount() { const sources = { ReactStable: 'https://unpkg.com/react@latest/umd/react.development.js', ReactDOMStable: 'https://unpkg.com/react-dom@latest/umd/react-dom.development.js', ReactDOMServerStable: 'https://unpkg.com/react-dom@latest/umd/react-dom-server.br...
@param {import('react-dom/server')} serverRenderer
componentDidMount
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function initGlobals(attribute, type) { if (useFastMode) { // Note: this is not giving correct results for warnings. // But it's much faster. if (pool[0]) { return pool[0].globals; } } else { document.title = `${attribute.name} (${type.name})`; } ...
@param {import('react-dom/server')} serverRenderer
initGlobals
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
componentWillUpdate(nextProps, nextState) { if ( nextState.sortOrder !== this.state.sortOrder || nextState.filter !== this.state.filter || nextState.completedHashes !== this.state.completedHashes || nextState.table !== this.state.table ) { this.attributes = this.getAttributes( ...
@param {import('react-dom/server')} serverRenderer
componentWillUpdate
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
getAttributes(table, rowPatternHashes, sortOrder, filter, completedHashes) { // Filter let filteredAttributes; switch (filter) { case ALL: filteredAttributes = attributes.filter(() => true); break; case COMPLETE: filteredAttributes = attributes.filter(attribute => { ...
@param {import('react-dom/server')} serverRenderer
getAttributes
javascript
facebook/react
fixtures/attribute-behavior/src/App.js
https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/src/App.js
MIT
function unmountComponent(node) { // ReactDOM was moved into a separate package in 0.14 if (needsReactDOM) { ReactDOM.unmountComponentAtNode(node); } else if (React.unmountComponentAtNode) { React.unmountComponentAtNode(node); } else { // Unmounting for React 0.4 and lower React....
Supports render.html, a piece of the hydration fixture. See /hydration
unmountComponent
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function createElement(value) { // React.createElement replaced function invocation in 0.12 if (needsCreateElement) { return React.createElement(value); } else { return value(); } }
Supports render.html, a piece of the hydration fixture. See /hydration
createElement
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function getQueryParam(key) { var pattern = new RegExp(key + '=([^&]+)(&|$)'); var matches = window.location.search.match(pattern); if (matches) { return decodeURIComponent(matches[1]); } handleError(new Error('No key found for' + key)); }
Supports render.html, a piece of the hydration fixture. See /hydration
getQueryParam
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function getBooleanQueryParam(key) { return getQueryParam(key) === 'true'; }
Supports render.html, a piece of the hydration fixture. See /hydration
getBooleanQueryParam
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function setStatus(label) { status.innerHTML = label; }
Supports render.html, a piece of the hydration fixture. See /hydration
setStatus
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function prerender() { setStatus('Generating markup'); return Promise.resolve() .then(function () { const element = createElement(Fixture); // Server rendering moved to a separate package along with ReactDOM // in 0.14.0 if (needsReactDOM) { return ReactDOMServe...
Supports render.html, a piece of the hydration fixture. See /hydration
prerender
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function render() { setStatus('Hydrating'); var element = createElement(Fixture); // ReactDOM was split out into another package in 0.14 if (needsReactDOM) { // Hydration changed to a separate method in React 16 if (ReactDOM.hydrate) { ReactDOM.hydrate(element, output); } els...
Supports render.html, a piece of the hydration fixture. See /hydration
render
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function handleError(error) { console.log(error); failed = true; setStatus('Javascript Error'); output.innerHTML = error; }
Supports render.html, a piece of the hydration fixture. See /hydration
handleError
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function loadScript(src) { return new Promise(function (resolve, reject) { var script = document.createElement('script'); script.async = true; script.src = src; script.onload = resolve; script.onerror = function (error) { reject(new Error('Unable to load ' + src)); }; ...
Supports render.html, a piece of the hydration fixture. See /hydration
loadScript
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function injectFixture(src) { Fixture = new Function(src + '\nreturn Fixture;')(); if (typeof Fixture === 'undefined') { setStatus('Failed'); output.innerHTML = 'Please name your root component "Fixture"'; } else { prerender().then(function () { if (getBooleanQueryParam('hydrate')...
Supports render.html, a piece of the hydration fixture. See /hydration
injectFixture
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function reloadFixture(code) { renders = 0; unmountComponent(output); injectFixture(code); }
Supports render.html, a piece of the hydration fixture. See /hydration
reloadFixture
javascript
facebook/react
fixtures/dom/public/renderer.js
https://github.com/facebook/react/blob/master/fixtures/dom/public/renderer.js
MIT
function findDOMNode(target) { const {needsReactDOM} = reactPaths(); if (needsReactDOM) { return ReactDOM.findDOMNode(target); } else { // eslint-disable-next-line return React.findDOMNode(target); } }
Provides a standard way to access a DOM node across all versions of React.
findDOMNode
javascript
facebook/react
fixtures/dom/src/find-dom-node.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/find-dom-node.js
MIT
function parseQuery(qstr) { var query = {}; var a = qstr.slice(1).split('&'); for (var i = 0; i < a.length; i++) { var b = a[i].split('='); query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || ''); } return query; }
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
parseQuery
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function loadScript(src) { let firstScript = document.getElementsByTagName('script')[0]; let scriptNode; return new Promise((resolve, reject) => { scriptNode = document.createElement('script'); scriptNode.async = 1; scriptNode.src = src; scriptNode.onload = () => resolve(); scriptNode.onerro...
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
loadScript
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function loadModules(SymbolSrcPairs) { let firstScript = document.getElementsByTagName('script')[0]; let imports = ''; SymbolSrcPairs.map(([symbol, src]) => { imports += `import ${symbol} from "${src}";\n`; imports += `window.${symbol} = ${symbol};\n`; }); return new Promise((resolve, reject) => { ...
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
loadModules
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function getVersion() { let query = parseQuery(window.location.search); return query.version || 'local'; }
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
getVersion
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function isLocal() { return getVersion() === 'local'; }
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
isLocal
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function reactPaths(version = getVersion()) { let query = parseQuery(window.location.search); let isProduction = query.production === 'true'; let environment = isProduction ? 'production.min' : 'development'; let reactPath = `react.${environment}.js`; let reactDOMPath = `react-dom.${environment}.js`; let re...
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
reactPaths
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function loadReact() { console.log('reactPaths', reactPaths()); const { reactPath, reactDOMPath, reactDOMClientPath, needsReactDOM, usingModules, } = reactPaths(); if (usingModules) { return loadModules([ ['React', reactPath], ['ReactDOM', reactDOMPath], ['ReactDOMClie...
Take a version from the window query string and load a specific version of React. @example http://localhost:3000?version=15.4.1 (Loads React 15.4.1)
loadReact
javascript
facebook/react
fixtures/dom/src/react-loader.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/react-loader.js
MIT
function getVersionTags() { return new Promise(resolve => { let cachedTags; if (canUseSessionStorage) { cachedTags = sessionStorage.getItem(TAGS_CACHE_KEY); } if (cachedTags) { cachedTags = JSON.parse(cachedTags); resolve(cachedTags); } else { fetch('https://api.github.com/...
Attempts to load tags from sessionStorage. In cases where sessionStorage is not available (Safari private browsing) or the tags are cached a fetch request is made to the GitHub API. Returns a promise so that the consuming module can always assume the request is async, even if its loaded from sessionStorage.
getVersionTags
javascript
facebook/react
fixtures/dom/src/tags.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/tags.js
MIT
async loadFixture() { const {fixturePath} = this.props; try { const module = await import(`.${fixturePath}`); this.setState({Fixture: module.default}); } catch (error) { console.error(error); this.setState({error}); } finally { this.setState({isLoading: false}); } }
A simple routing component that renders the appropriate fixture based on the location pathname.
loadFixture
javascript
facebook/react
fixtures/dom/src/components/fixtures/index.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/index.js
MIT
render() { const {Fixture, error, isLoading} = this.state; if (isLoading) { return null; } if (error) { return <FixtureError error={error} />; } return <Fixture />; }
A simple routing component that renders the appropriate fixture based on the location pathname.
render
javascript
facebook/react
fixtures/dom/src/components/fixtures/index.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/index.js
MIT
function FixtureError({error}) { return ( <section> <h2>Error loading fixture</h2> <p>{error.message}</p> </section> ); }
A simple routing component that renders the appropriate fixture based on the location pathname.
FixtureError
javascript
facebook/react
fixtures/dom/src/components/fixtures/index.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/index.js
MIT
render() { const attrs = this.inputAttrs(); return ( <div> <p> <b>{attrs.type}</b> input type ({attrs.value}) </p> <p> <input type={attrs.type} value={attrs.value} onChange={this.onInputChange} /> <label> ...
This test case was originally provided by @richsoni, https://github.com/facebook/react/issues/8116
render
javascript
facebook/react
fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js
MIT
inputAttrs() { if (this.state.fullDate) { return { type: 'datetime-local', value: this.state.date.toISOString().replace(/\..*Z/, ''), }; } else { return { type: 'date', value: this.state.date.toISOString().replace(/T.*/, ''), }; } }
This test case was originally provided by @richsoni, https://github.com/facebook/react/issues/8116
inputAttrs
javascript
facebook/react
fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/date-inputs/switch-date-test-case.js
MIT
function compile(raw) { return transform(raw, {presets}).code; }
Babel works across all browsers, however it requires many polyfills.
compile
javascript
facebook/react
fixtures/dom/src/components/fixtures/hydration/code-transformer.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/hydration/code-transformer.js
MIT
render() { const {error, className} = this.props; if (!error) { return null; } if (supportsDetails) { const [summary, ...body] = error.message.split(/\n+/g); if (body.length >= 0) { return <div className={className}>{summary}</div>; } return ( <details c...
Prevent IE9 from raising an error on an unrecognized element: See https://github.com/facebook/react/issues/13610
render
javascript
facebook/react
fixtures/dom/src/components/fixtures/hydration/Code.js
https://github.com/facebook/react/blob/master/fixtures/dom/src/components/fixtures/hydration/Code.js
MIT
function getAdditionalModulePaths(options = {}) { const baseUrl = options.baseUrl; if (!baseUrl) { return ''; } const baseUrlResolved = path.resolve(paths.appPath, baseUrl); // We don't need to do anything if `baseUrl` is set to `node_modules`. This is // the default behavior. if (path.relative(pat...
Get additional module paths based on the baseUrl of a compilerOptions object. @param {Object} options
getAdditionalModulePaths
javascript
facebook/react
fixtures/flight/config/modules.js
https://github.com/facebook/react/blob/master/fixtures/flight/config/modules.js
MIT
function getWebpackAliases(options = {}) { const baseUrl = options.baseUrl; if (!baseUrl) { return {}; } const baseUrlResolved = path.resolve(paths.appPath, baseUrl); if (path.relative(paths.appPath, baseUrlResolved) === '') { return { src: paths.appSrc, }; } }
Get webpack aliases based on the baseUrl of a compilerOptions object. @param {*} options
getWebpackAliases
javascript
facebook/react
fixtures/flight/config/modules.js
https://github.com/facebook/react/blob/master/fixtures/flight/config/modules.js
MIT
function getJestAliases(options = {}) { const baseUrl = options.baseUrl; if (!baseUrl) { return {}; } const baseUrlResolved = path.resolve(paths.appPath, baseUrl); if (path.relative(paths.appPath, baseUrlResolved) === '') { return { '^src/(.*)$': '<rootDir>/src/$1', }; } }
Get jest aliases based on the baseUrl of a compilerOptions object. @param {*} options
getJestAliases
javascript
facebook/react
fixtures/flight/config/modules.js
https://github.com/facebook/react/blob/master/fixtures/flight/config/modules.js
MIT
function getModules() { // Check if TypeScript is setup const hasTsConfig = fs.existsSync(paths.appTsConfig); const hasJsConfig = fs.existsSync(paths.appJsConfig); if (hasTsConfig && hasJsConfig) { throw new Error( 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please...
Get jest aliases based on the baseUrl of a compilerOptions object. @param {*} options
getModules
javascript
facebook/react
fixtures/flight/config/modules.js
https://github.com/facebook/react/blob/master/fixtures/flight/config/modules.js
MIT
function provokeChromeCrash() { React.startTransition(async () => { console.log('Default transition triggered'); await new Promise(resolve => { setTimeout( () => { history.pushState( {}, '', `?chrome-crash-419746417=${performance.n...
Repro for https://issues.chromium.org/u/1/issues/419746417
provokeChromeCrash
javascript
facebook/react
fixtures/flight/src/Navigate.js
https://github.com/facebook/react/blob/master/fixtures/flight/src/Navigate.js
MIT
ReactElement = function (type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, // Built-in properties that belong on the element type: type, key: key, ref: ref, props: props, // Rec...
Factory method to create a new React element. This no longer adheres to the class pattern, so do not use new to call it. Also, instanceof check will not work. Instead test $$typeof field against Symbol.for('react.element') to check if something is a React Element. @param {*} type @param {*} props @param {*} key @param...
ReactElement
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function jsxDEV(type, config, maybeKey, source, self) { { var propName; // Reserved names are extracted var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie. <div {...props} key="Hi" /...
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
jsxDEV
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function setCurrentlyValidatingElement$1(element) { currentlyValidatingElement = element; }
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
setCurrentlyValidatingElement$1
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function isValidElement(object) { { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
isValidElement
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function getDeclarationErrorAddendum() { { if (ReactCurrentOwner$1.current) { var name = ReactCurrentOwner$1.current.getName(); if (name) { return '\n\nCheck the render method of `' + name + '`.'; } } return ''; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
getDeclarationErrorAddendum
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function getSourceInfoErrorAddendum(source) { { if (source !== undefined) { var fileName = source.fileName.replace(/^.*[\\\/]/, ''); var lineNumber = source.lineNumber; return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; } return ''; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
getSourceInfoErrorAddendum
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function getCurrentComponentErrorInfo(parentType) { { var info = getDeclarationErrorAddendum(); if (!info) { var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; if (parentName) { info = "\n\nCheck the top-level render call using <" + ...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
getCurrentComponentErrorInfo
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function validateExplicitKey(element, parentType) { { if (!element._store || element._store.validated || element.key != null) { return; } element._store.validated = true; var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); if (ownerHasKeyUseWarning[currentComponentErr...
Warn if the element doesn't have an explicit key assigned to it. This element is in an array. The array could grow and shrink or be reordered. All children that haven't already been validated are required to have a "key" property assigned to it. Error statuses are cached so a warning will only be shown once. @internal...
validateExplicitKey
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function validateChildKeys(node, parentType) { { if (typeof node !== 'object') { return; } if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i]; if (isValidElement(child)) { validateExplicitKey(child, parentType); } } ...
Ensure that every element either is passed in a static location, in an array with an explicit keys property defined, or in an object literal with valid key property. @internal @param {ReactNode} node Statically passed child of any type. @param {*} parentType node's parent's type.
validateChildKeys
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function validatePropTypes(element) { { var type = element.type; if (type === null || type === undefined || typeof type === 'string') { return; } var propTypes; if (typeof type === 'function') { propTypes = type.propTypes; } else if (typeof type === 'object' && (type.$$typeof ==...
Given an element, validate that its props follow the propTypes definition, provided by the type. @param {ReactElement} element
validatePropTypes
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function validateFragmentProps(fragment) { { var keys = Object.keys(fragment.props); for (var i = 0; i < keys.length; i++) { var key = keys[i]; if (key !== 'children' && key !== 'key') { setCurrentlyValidatingElement$1(fragment); error('Invalid prop `%s` supplied to `React.Fragm...
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
validateFragmentProps
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
function jsxWithValidation(type, props, key, isStaticChildren, source, self) { { var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to // succeed and there will likely be errors in render. if (!validType) { var info = ''; if (typ...
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
jsxWithValidation
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js
MIT
ReactElement = function (type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, // Built-in properties that belong on the element type: type, key: key, ref: ref, props: props, // Rec...
Factory method to create a new React element. This no longer adheres to the class pattern, so do not use new to call it. Also, instanceof check will not work. Instead test $$typeof field against Symbol.for('react.element') to check if something is a React Element. @param {*} type @param {*} props @param {*} key @param...
ReactElement
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function jsxDEV(type, config, maybeKey, source, self) { { var propName; // Reserved names are extracted var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie. <div {...props} key="Hi" /...
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
jsxDEV
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function setCurrentlyValidatingElement$1(element) { currentlyValidatingElement = element; }
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
setCurrentlyValidatingElement$1
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function isValidElement(object) { { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
isValidElement
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function getDeclarationErrorAddendum() { { if (ReactCurrentOwner$1.current) { var name = ReactCurrentOwner$1.current.getName(); if (name) { return '\n\nCheck the render method of `' + name + '`.'; } } return ''; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
getDeclarationErrorAddendum
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function getSourceInfoErrorAddendum(source) { { if (source !== undefined) { var fileName = source.fileName.replace(/^.*[\\\/]/, ''); var lineNumber = source.lineNumber; return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; } return ''; } }
Verifies the object is a ReactElement. See https://reactjs.org/docs/react-api.html#isvalidelement @param {?object} object @return {boolean} True if `object` is a ReactElement. @final
getSourceInfoErrorAddendum
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function getCurrentComponentErrorInfo(parentType) { { var info = getDeclarationErrorAddendum(); if (!info) { var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; if (parentName) { info = "\n\nCheck the top-level render call using <" + ...
Warn if there's no key explicitly set on dynamic arrays of children or object keys are not valid. This allows us to keep track of children between updates.
getCurrentComponentErrorInfo
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function validateExplicitKey(element, parentType) { { if (!element._store || element._store.validated || element.key != null) { return; } element._store.validated = true; var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); if (ownerHasKeyUseWarning[currentComponentErr...
Warn if the element doesn't have an explicit key assigned to it. This element is in an array. The array could grow and shrink or be reordered. All children that haven't already been validated are required to have a "key" property assigned to it. Error statuses are cached so a warning will only be shown once. @internal...
validateExplicitKey
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function validateChildKeys(node, parentType) { { if (typeof node !== 'object') { return; } if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i]; if (isValidElement(child)) { validateExplicitKey(child, parentType); } } ...
Ensure that every element either is passed in a static location, in an array with an explicit keys property defined, or in an object literal with valid key property. @internal @param {ReactNode} node Statically passed child of any type. @param {*} parentType node's parent's type.
validateChildKeys
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function validatePropTypes(element) { { var type = element.type; if (type === null || type === undefined || typeof type === 'string') { return; } var propTypes; if (typeof type === 'function') { propTypes = type.propTypes; } else if (typeof type === 'object' && (type.$$typeof ==...
Given an element, validate that its props follow the propTypes definition, provided by the type. @param {ReactElement} element
validatePropTypes
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function validateFragmentProps(fragment) { { var keys = Object.keys(fragment.props); for (var i = 0; i < keys.length; i++) { var key = keys[i]; if (key !== 'children' && key !== 'key') { setCurrentlyValidatingElement$1(fragment); error('Invalid prop `%s` supplied to `React.Fragm...
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
validateFragmentProps
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function jsxWithValidation(type, props, key, isStaticChildren, source, self) { { var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to // succeed and there will likely be errors in render. if (!validType) { var info = ''; if (typ...
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
jsxWithValidation
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function jsxWithValidationStatic(type, props, key) { { return jsxWithValidation(type, props, key, true); } }
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
jsxWithValidationStatic
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
function jsxWithValidationDynamic(type, props, key) { { return jsxWithValidation(type, props, key, false); } }
Given a fragment, validate that it can only be provided with fragment props @param {ReactElement} fragment
jsxWithValidationDynamic
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js
MIT
ReactElement = function (type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, // Built-in properties that belong on the element type: type, key: key, ref: ref, props: props, // Rec...
Factory method to create a new React element. This no longer adheres to the class pattern, so do not use new to call it. Also, instanceof check will not work. Instead test $$typeof field against Symbol.for('react.element') to check if something is a React Element. @param {*} type @param {*} props @param {*} key @param...
ReactElement
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
MIT
function jsxDEV(type, config, maybeKey, source, self) { { var propName; // Reserved names are extracted var props = {}; var key = null; var ref = null; // Currently, key can be spread in as a prop. This causes a potential // issue if key is also explicitly declared (ie. <div {...props} key="Hi" /...
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
jsxDEV
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
MIT
function setCurrentlyValidatingElement$1(element) { currentlyValidatingElement = element; }
https://github.com/reactjs/rfcs/pull/107 @param {*} type @param {object} props @param {string} key
setCurrentlyValidatingElement$1
javascript
facebook/react
fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
https://github.com/facebook/react/blob/master/fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js
MIT