What exactly means dependency in react.js?

Viewed 5278

I am studying React.js., and I have started by setting the project folders to try some codes. But, some terms are confusing me as a beginner. One of them is "dependency." When I search for it, the result is only related to dependency injection stuff, but what is the "dependency" itself?

3 Answers

A dependency is some third-party code that your application depends on. Just like a child depends on its parent, your application depends on other people's code. A piece of code becomes a true dependency when your own application cannot function without it.

If you want to look at the dependencies you're using, you can find them in the package.json file under the dependencies key.

Well, dependencies are those things that you need to install and import for doing specific things, for example, if you want to add routing(moving from one page to another which changes your URL) in your react project then you need to install react-router-dom dependency by doing

npm install react-router-dom

A dependency is just a package that your project uses.

Very few javascript projects are entirely self-contained. When your project needs code from other projects in order to do its thing, those other projects are "dependencies"; your project depends on them to run.

When you install third-party packages via npm install <package>, you're adding a dependency.

Your project's package.json file includes a list of your project's dependencies.

Related