Skip to content

Commit 336fe88

Browse files
committed
Add render method interview questions
1 parent de4c7e2 commit 336fe88

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@
251251
|235| [What is the behavior of uncaught errors in react 16?](#what-is-the-behavior-of-uncaught-errors-in-react-16)|
252252
|236| [What is the proper placement for error boundaries?](#what-is-the-proper-placement-for-error-boundaries)|
253253
|237| [What is the benefit of component stack trace from error boundary?](#what-is-the-benefit-of-component-stack-trace-from-error-boundary)|
254+
|238| [What is the required method to be defined for a class component?](#what-is-the-required-method-to-be-defined-for-a-class-component)|
255+
|239| [What are the possible return types of render method?](#what-are-the-possible-return-types-of-render-method)|
254256

255257
## Core React
256258

@@ -1032,7 +1034,7 @@
10321034
ReactDOM.createPortal(child, container)
10331035
```
10341036
1035-
The first argument is any renderable React child, such as an element, string, or fragment. The second argument is a DOM element.
1037+
The first argument is any render-able React child, such as an element, string, or fragment. The second argument is a DOM element.
10361038
10371039
49. ### What are stateless components?
10381040
@@ -4032,4 +4034,14 @@
40324034
237. ### What is the benefit of component stack trace from error boundary?
40334035
Apart from error messages and javascript stack, React16 will display the component stack trace with file names and line numbers using error boundary concept. For example, BuggyCounter component displays the component stack trace as below,
40344036
4035-
![stacktrace](images/error_boundary.png)
4037+
![stacktrace](images/error_boundary.png)
4038+
4039+
238. ### What is the required method to be defined for a class component?
4040+
The render() method is the only required method in a class component. i.e, All methods other than render method are optional for a class component.
4041+
239. ### What are the possible return types of render method?
4042+
Below are the list of following types used and return from render method,
4043+
1. **React elements:** Elements that instruct React to render a DOM node. It includes html elements such as <div/> and user defined elements.
4044+
2. **Arrays and fragments:** Return multiple elements to render as Arrays and Fragments to wrap multiple elements
4045+
3. **Portals:** Render children into a different DOM subtree.
4046+
4. **String and numbers:** Render both Strings and Numbers as text nodes in the DOM
4047+
5. **Booleans or null:** Doesn't render anything but these types are used to conditionally render content.

0 commit comments

Comments
 (0)