Reactjs Interview
Reactjs Interview
3. Creates a new DOM if element updates. 3. Updates the JSX if element updates.
JSX is a syntax extension to JavaScript and comes with the full power of
JavaScript. JSX produces React “elements”. You can embed any JavaScript
expression in JSX by wrapping it in curly braces.
For example, below is the syntax for a basic element in React with JSX and its equivalent without it.
React JS Interview Question
Using an ES6 class to write the same component is a little different. Instead of
using a method from the react library, we extend an ES6 class that the library
defines, Component.
React JS Interview Question
Q10. What are the differences between a class component and functional
component?
Class components allows us to use additional features such as local state
and lifecycle hooks. Also, to enable our component to have direct access to
our store and thus holds state.
When our component just receives props and renders them to the page, this
is a ‘stateless component’, for which a pure function can be used. These are
also called dumb components or presentational components.
React JS Interview Question
The state is a data structure that starts with a default value when a
Component mounts. It may be mutated across time, mostly as a result of
user events.
Props (short for properties) are a Component’s configuration. Props are how
components talk to each other. They are received from above component
and immutable as far as the Component receiving them is concerned. A
Component cannot change its props, but it is responsible for putting together
the props of its child Components. Props do not have to just be data —
callback functions may be passed in as props.
React JS Interview Question
The basic idea of Redux is that the entire application state is kept in a single
store. The store is simply a javascript object. The only way to change the
state is by firing actions from your application and then writing reducers for
these actions that modify the state. The entire state transition is kept inside
reducers and should not have any side-effects.
Redux is based on the idea that there should be only a single source of truth
for your application state, be it UI state like which tab is active or Data state
like the user profile details.
React JS Interview Question
This relates to stateful DOM components (form elements) and the difference:
● A Controlled Componentis one that takes its current value through props
and notifies changes through callbacks like onChange. A parent
component “controls” it by handling the callback and managing its own
state and passing the new values as props to the controlled component.
You could also call this a “dumb component”.
React JS Interview Question
● Action— Actions are payloads of information that send data from our
application to our store. They are the only source of information for the
store. We send them to the store using store.dispatch(). Primarly, they
are just an object describes what happened in our app.
React JS Interview Question
● Store — The Store is the object that brings Action and Reducer
together. The store has the following responsibilities: Holds application
state; Allows access to state via getState(); Allows state to be updated
viadispatch(action); Registers listeners via subscribe(listener); Handles
unregistering of listeners via the function returned bysubscribe(listener).
React JS Interview Question
React is a JavaScript library, supporting both front end web and being run on
the server, for building user interfaces and web applications.
● Just like how React is based on components, in React Router v4, the
API is ‘All About Components’. A Router can be visualized as a single
root component (<BrowserRouter>) in which we enclose the specific
child routes (<route>).
React JS Interview Question
● No need to manually set History value: In React Router v4, all we need
to do is wrap our routes within the <BrowserRouter> component.
● The packages are split: Three packages one each for Web, Native and
Core. This supports the compact size of our application. It is easy to
switch over based on a similar coding style.
React JS Interview Question
I hope this set of React Interview Questions and Answers will help you in
preparing for your interviews. All the best!