farshid
farshid

Reputation: 166

find out where one react component is used?

is there a way to find out where a react component is used in other components?

for example:

navbar components is used in app.js

import React from 'react';

const Navbar = () => {
    return <div>this is Navbar</div>;
};

export default Navbar;


import React from 'react'; import Navbar from './Navbar';

const App = () => {return (<div><Navbar /></div>); };

export default App;

Upvotes: 2

Views: 6494

Answers (2)

Mahmoud
Mahmoud

Reputation: 1395

There's two ways to find:

  1. React Developer Tools extension (recommended) tool for debugging. It has a Search bar (text or/regex/)

enter image description here

  1. Most of IDE/Code editors now days has the ability to help you find out component usage

Cheers and I hope this helps

Upvotes: 3

isabellabrookes
isabellabrookes

Reputation: 83

Most IDEs should be able to find references to the component. Otherwise, a simple search should find it.

Upvotes: 3

Related Questions