React JS Interview Qusestions
React JS Interview Qusestions
1. What is ReactJS?
Open-source, component-based front-end JavaScript library.
Developed by Facebook.
2. Benefits of ReactJS:
Easy to learn:
Reusable Components:
Virtual DOM:
SEO-Friendly:
Developer Tools:
Performance Enhancement:
Key features:
Code linting.
CSS auto-prefixing.
4. Features of ReactJS:
Virtual DOM: React creates an in-memory representation of the real DOM,
leading to faster UI updates.
One-way Data Binding: Data flows from parent to child components, ensuring
controlled state management.
5. Disadvantages of ReactJS:
Dynamic Technology: Constant updates require continuous learning.
View Part Only: ReactJS focuses solely on the UI layer, requiring additional
libraries for full-stack development.
Developed by Facebook.
AngularJS:
Developed by Google.
Does not support older browsers like Internet Explorer without ES5 polyfills.
Type-safe.
cloneElement :
Returns JSX.
Example:
js
Copy code
function Hello({ message }) {
return <h1>Hello, {message}</h1>;
}
Class Components:
Example:
js
Copy code
class App extends React.Component {
render() {
Example:
js
Copy code
MyApp.defaultProps = {
randomObject: {}
};
Mutable.
Props:
Immutable.
Callback (optional):
Example:
js
Copy code
render() {
return (<MyInput onChange={(e) => this.handleOnChange
(e)} />);
Example:
js
Copy code
const { Provider, Consumer } = React.createContext(default
Value);
Example:
js
Copy code
<MyContext.Consumer>
{value => /* Render something based on context value */}
</MyContext.Consumer>
Compares the new virtual DOM to the previous one and updates only the
changed elements.
Example:
js
Copy code
class MyComponent extends React.PureComponent {
render() {
return <div>{this.props.name}</div>;
}
}