From 259609116730ee6d1d527f005935a4a56726c786 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Tue, 19 Sep 2023 23:20:10 +0600 Subject: [PATCH] Add more questions --- .../react/content/flush-sync.md | 9 +++++++ src/data/question-groups/react/react.md | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/data/question-groups/react/content/flush-sync.md diff --git a/src/data/question-groups/react/content/flush-sync.md b/src/data/question-groups/react/content/flush-sync.md new file mode 100644 index 000000000..41a98e66c --- /dev/null +++ b/src/data/question-groups/react/content/flush-sync.md @@ -0,0 +1,9 @@ +The `flushSync` function in React is used to flush updates synchronously. It schedules updates to be performed inside a high-priority task, ensuring that the updates are executed immediately and synchronously before returning control to the caller. + +```js +import { flushSync } from 'react-dom'; + +flushSync(callback); +``` + +This is useful in situations where you need the DOM to be updated immediately, such as for measurements or to ensure synchronous rendering. However, excessive use of `flushSync` can lead to degraded performance, so it should be used judiciously. diff --git a/src/data/question-groups/react/react.md b/src/data/question-groups/react/react.md index 3468966a3..41c86289e 100644 --- a/src/data/question-groups/react/react.md +++ b/src/data/question-groups/react/react.md @@ -177,7 +177,7 @@ questions: - question: What are fragments in React? answer: | React doesn't allow returning multiple elements from a component. You can use fragments to return multiple elements. - + Fragments in React allow for a group of elements to be returned from a component's render method without adding an extra node to the DOM. They are useful when you want to return multiple elements without wrapping them in a parent container. topics: - 'Core' @@ -187,4 +187,27 @@ questions: topics: - 'Core' - 'Intermediate' + - question: What is Concurrent React (Concurrent Mode)? + answer: | + Concurrent React, previously referred to as Concurrent Mode, is a set of new features in React 18 that allows React to interrupt the rendering process to consider more urgent tasks, making it possible for React to be more responsive to user input and produce smoother user experiences. It lets React keep the UI responsive while rendering large component trees by splitting the rendering work into smaller chunks and spreading it over multiple frames. + topics: + - 'Core' + - 'Intermediate' + - question: What is the new `startTransition` API? + answer: | + The `startTransition` API in React 18 allows developers to mark certain updates as **transitions** so they can be deprioritized, allowing other, more urgent updates to be processed first. This ensures that the UI remains responsive during updates that might take some time, like data fetching. + topics: + - 'Core' + - 'Intermediate' + - question: What is the purpose of `flushSync` in React? + answer: flush-sync.md + topics: + - 'Core' + - 'Intermediate' + - question: What is the `renderToString` in React? + answer: | + The `renderToString` function in React is part of the `react-dom/server` package and is used to render React components on the server-side to a static HTML string. It is commonly used for server-side rendering (SSR) in React. + topics: + - 'Core' + - 'Intermediate' ---