Home / File/ shared.js — react Source File

shared.js — react Source File

Architecture documentation for shared.js, a javascript file in the react codebase.

File javascript BabelCompiler Optimization 14 functions 4 classes

Entity Profile

Relationship Graph

Source Code

/* eslint-disable react/react-in-jsx-scope, react/jsx-no-undef */
/* global React ReactCache ReactDOM SchedulerTracing ScheduleTracing  */

const apps = [];

const pieces = React.version.split('.');
const major =
  pieces[0] === '0' ? parseInt(pieces[1], 10) : parseInt(pieces[0], 10);
const minor =
  pieces[0] === '0' ? parseInt(pieces[2], 10) : parseInt(pieces[1], 10);

// Convenience wrapper to organize API features in DevTools.
function Feature({children, label, version}) {
  return (
    <div className="Feature">
      <div className="FeatureHeader">
        <code className="FeatureCode">{label}</code>
        <small>{version}</small>
      </div>
      {children}
    </div>
  );
}

// Simplify interaction tracing for tests below.
let trace = null;
if (typeof SchedulerTracing !== 'undefined') {
  trace = SchedulerTracing.unstable_trace;
} else if (typeof ScheduleTracing !== 'undefined') {
  trace = ScheduleTracing.unstable_trace;
} else {
  trace = (_, __, callback) => callback();
}

// https://github.com/facebook/react/blob/main/CHANGELOG.md
switch (major) {
  case 16:
    switch (minor) {
      case 7:
        if (typeof React.useState === 'function') {
          // Hooks
          function Hooks() {
            const [count, setCount] = React.useState(0);
            const incrementCount = React.useCallback(
              () => setCount(count + 1),
              [count]
            );
            return (
              <div>
                count: {count}{' '}
                <button onClick={incrementCount}>increment</button>
              </div>
            );
          }
          apps.push(
            <Feature key="Hooks" label="Hooks" version="16.7+">
              <Hooks />
            </Feature>
          );
        }
// ... (269 more lines)

Domain

Subdomains

Frequently Asked Questions

What does shared.js do?
shared.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in shared.js?
shared.js defines 14 function(s): AnonymousFunction, AnonymousMemoized, CustomName, Even, Feature, Hooks, LabelComponent, LazyWithDefaultProps, NamedFunction, TopLevelWrapperForDevTools, and 4 more.
Where is shared.js in the architecture?
shared.js is located at fixtures/devtools/regression/shared.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/devtools/regression).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free