DEV Community

Cover image for React JS
Shubham Lakhara
Shubham Lakhara

Posted on • Updated on

React JS

Difference package.json and package-lock.json files?

Q1: why package.lock.json is necessary when you have package.json in your project application?

ANS: package.lock.json is created for locking the dependency with the installed version. It will install the exact latest version of that package in your application and save it in package.json.

DIFFERENCE IS:

Without package.lock.json, there might be some differences in installed versions in different environments. To overcome this problem, package.lock.json is created to have the same results in every environment.

GFG


useState

Q.1 What is the use of useState() in React Hooks?

  • It allows to track the state in a functional component in React.

Props

  • React components use props to communicate with each other.
  • Props are also how you pass data from one component to another, as parameters.
  • In react, the prop stands for "Properties". They are plain JavaScript objects.
  • Props are used to store data that can be accessed by the children of a React component.
  • React Props are like function arguments in JavaScript.
  • Props are also how you pass data from one component to another, as parameters.
  • props

Components

Components are independent and reusable bits of code.

Top comments (0)