Repository: facebook/react
File: packages/react-devtools-shared/src/backend/console.js (JavaScript)

Code before:
          for (const renderer of injectedRenderers.values()) {
            const currentDispatcherRef = getDispatcherRef(renderer);
            const {getCurrentFiber, onErrorOrWarning, workTagMap} = renderer;
            const current: ?Fiber = getCurrentFiber();
            if (current != null) {
              try {
                if (shouldShowInlineWarningsAndErrors) {
                  // patch() is called by two places: (1) the hook and (2) the renderer backend.
                  // The backend is what implements a message queue, so it's the only one that injects onErrorOrWarning.
                  if (typeof onErrorOrWarning === 'function') {
                    onErrorOrWarning(
                      current,
                      ((method: any): 'error' | 'warn'),
                      // Restore and copy args before we mutate them (e.g. adding the component stack)
                      restorePotentiallyModifiedArgs(args),
                    );
                  }
                }

                if (
                  consoleSettingsRef.appendComponentStack &&
                  !supportsNativeConsoleTasks(current)
                ) {
                  const enableOwnerStacks = supportsOwnerStacks(current);
                  let componentStack = '';
                  if (supportsOwnerStacks(current)) {
                    // Prefix the owner stack with the current stack. I.e. what called
                    // console.error. While this will also be part of the native stack,
                    // it is hidden and not presented alongside this argument so we print
                    // them all together.
                    const topStackFrames = formatOwnerStack(
                      new Error('react-stack-top-frame'),
                    );
                    if (topStackFrames) {
                      componentStack += '\n' + topStackFrames;
                    }
                    componentStack += getOwnerStackByFiberInDev(
                      workTagMap,
                      current,
                      (currentDispatcherRef: any),
                    );
                  } else {
                    componentStack = getStackByFiberInDevAndProd(
                      workTagMap,
                      current,
                      (currentDispatcherRef: any),
                    );
                  }
                  if (componentStack !== '') {
                    // Create a fake Error so that when we print it we get native source maps. Every
                    // browser will print the .stack property of the error and then parse it back for source

Review comment (suggestion):
```suggestion
                  if (enableOwnerStacks) {
```

Code after:
          for (const renderer of injectedRenderers.values()) {
            const currentDispatcherRef = getDispatcherRef(renderer);
            const {getCurrentFiber, onErrorOrWarning, workTagMap} = renderer;
            const current: ?Fiber = getCurrentFiber();
            if (current != null) {
              try {
                if (shouldShowInlineWarningsAndErrors) {
                  // patch() is called by two places: (1) the hook and (2) the renderer backend.
                  // The backend is what implements a message queue, so it's the only one that injects onErrorOrWarning.
                  if (typeof onErrorOrWarning === 'function') {
                    onErrorOrWarning(
                      current,
                      ((method: any): 'error' | 'warn'),
                      // Restore and copy args before we mutate them (e.g. adding the component stack)
                      restorePotentiallyModifiedArgs(args),
                    );
                  }
                }

                if (
                  consoleSettingsRef.appendComponentStack &&
                  !supportsNativeConsoleTasks(current)
                ) {
                  const enableOwnerStacks = supportsOwnerStacks(current);
                  let componentStack = '';
                  if (enableOwnerStacks) {
                    // Prefix the owner stack with the current stack. I.e. what called
                    // console.error. While this will also be part of the native stack,
                    // it is hidden and not presented alongside this argument so we print
                    // them all together.
                    const topStackFrames = formatOwnerStack(
                      new Error('react-stack-top-frame'),
                    );
                    if (topStackFrames) {
                      componentStack += '\n' + topStackFrames;
                    }
                    componentStack += getOwnerStackByFiberInDev(
                      workTagMap,
                      current,
                      (currentDispatcherRef: any),
                    );
                  } else {
                    componentStack = getStackByFiberInDevAndProd(
                      workTagMap,
                      current,
                      (currentDispatcherRef: any),
                    );
                  }
                  if (componentStack !== '') {
                    // Create a fake Error so that when we print it we get native source maps. Every
                    // browser will print the .stack property of the error and then parse it back for source