DEV Community

Devi
Devi

Posted on • Edited on

Simple React Interview Questions and Answers 🔍

1.What is state & props / Difference between state and props:
In reacting while building an application we'll break the page into small reusable components to make it more readable and to manage easily,
State: we've to use state to manage data inside a component.
Props: Props are some data that a component receives from another component

2. What "create-react-app" will do?
create-react-app will create a react project with necessary packages and bundlers (react by default has a bundler called web pack). It'll compile and run the project in localhost.

3. what is the robot.txt file in react?
if web designers create something on their website and don't want Google or other search engines to access it, they'll write it in robot.txt and it will be helpful for SEO too.

4. Types of components in react?
Functional components: A normal JS function that can manage multiple functions inside that.
Class-based components: created using class keywords in Javascript.
Functional is a new way, easy to use compared to class components

5. What is JSX?
JavaScript XML, which will be used to create HTML elements inside DOM.

6. what are Hooks in react?
Hooks are utility functions. to manage a state in functional components we'll use state (useState hook) from react.

useState: to create a special dynamic variable by re-rendering automatically.
UseState will return an array 
const [data,setData] = useState('')

Top comments (0)