Skip to content

Bug: In a recursive components, _debugSource doesn't get updated #26837

@vlad-karnauch

Description

@vlad-karnauch

with the following component:

export default function App({ title }: { title?: string }) {
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    setIsLoading(false);
  }, []);

  if (isLoading || !title) {
    return <div data-id="line12">Loading...</div>;
  }

  return (
    <div data-id="line-15">
      Loaded
      <App />
    </div>
  );
}

when react-dom updates the div (the one with data-id="line12" to the one with data-id="line-15")
it doesn't update _debugSource attribute on the fiber, that's why devtools displays the wrong line number
(see image below)

React version:
18.*

Steps To Reproduce

  1. clone the github repo below
  2. start the project and open it in the browser
  3. open react-devtools
  4. select the root div element inside App
    The source location is wrong.

Or, you can open the following codesandbox:
codesandbox
open the preview in a separate browser tab, and see the issue in devtools

Link to code example:

github-repo

The current behavior

Screenshot 2023-05-21 at 17 43 08

The expected behavior

source in react devtools should be App.tsx:15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions