Skip to content

Commit 673ea06

Browse files
committed
chore: format all files
1 parent 634e5af commit 673ea06

File tree

46 files changed

+142
-201
lines changed
  • questions
    • explain-one-way-data-flow-of-react-and-its-benefits
    • explain-server-side-rendering-of-react-applications-and-its-benefits
    • explain-static-generation-of-react-applications-and-its-benefits
    • explain-the-composition-pattern-in-react
    • explain-the-presentational-vs-container-component-pattern-in-react
    • explain-what-happens-when-setstate-is-called-in-react
    • explain-what-react-hydration-is
    • how-do-you-debug-react-applications
    • how-do-you-decide-between-using-react-state-context-and-external-state-managers
    • how-do-you-handle-asynchronous-data-loading-in-react-applications
    • how-do-you-localize-react-applications
    • how-do-you-reset-a-components-state-in-react
    • how-do-you-test-react-applications
    • how-does-virtual-dom-in-react-work-what-are-its-benefits-and-downsides
    • what-are-error-boundaries-in-react-for
    • what-are-higher-order-components-in-react
    • what-are-react-fragments-used-for
    • what-are-react-portals-used-for
    • what-are-render-props-in-react-and-what-are-they-for
    • what-are-some-common-pitfalls-when-doing-data-fetching-in-react
    • what-are-some-pitfalls-about-using-context-in-react
    • what-are-some-react-anti-patterns
    • what-are-the-benefits-of-using-hooks-in-react
    • what-are-the-rules-of-react-hooks
    • what-does-re-rendering-mean-in-react
    • what-does-the-dependency-array-of-useeffect-affect
    • what-is-code-splitting-in-a-react-application
    • what-is-forwardref-in-react-used-for
    • what-is-jsx-and-how-does-it-work
    • what-is-react-fiber-and-how-is-it-an-improvement-over-the-previous-approach
    • what-is-react-strict-mode-and-what-are-its-benefits
    • what-is-react-suspense-and-what-does-it-enable
    • what-is-reconciliation-in-react
    • what-is-the-consequence-of-using-array-indices-as-the-value-for-key-s-in-react
    • what-is-the-difference-between-controlled-and-uncontrolled-react-components
    • what-is-the-difference-between-react-node-react-element-and-a-react-component
    • what-is-the-difference-between-state-and-props-in-react
    • what-is-the-purpose-of-callback-function-argument-format-of-setstate-in-react-and-when-should-it-be-used
    • what-is-the-purpose-of-the-key-prop-in-react
    • what-is-the-usecallback-hook-in-react-and-when-should-it-be-used
    • what-is-the-useid-hook-in-react-and-when-should-it-be-used
    • what-is-the-usememo-hook-in-react-and-when-should-it-be-used
    • what-is-the-usereducer-hook-in-react-and-when-should-it-be-used
    • what-is-the-useref-hook-in-react-and-when-should-it-be-used
    • what-is-virtual-dom-in-react
    • why-does-react-recommend-against-mutating-state

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+142
-201
lines changed

questions/explain-one-way-data-flow-of-react-and-its-benefits/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,3 @@ One-way data flow can lead to better performance because it reduces the complexi
7676
- [React documentation on components and props](https://reactjs.org/docs/components-and-props.html)
7777
- [React documentation on state and lifecycle](https://reactjs.org/docs/state-and-lifecycle.html)
7878
- [React documentation on lifting state up](https://reactjs.org/docs/lifting-state-up.html)
79-

questions/explain-server-side-rendering-of-react-applications-and-its-benefits/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ export default Home;
6767
- [Next.js Documentation](https://nextjs.org/docs)
6868
- [React Server Components](https://reactjs.org/docs/react-server.html)
6969
- [Server-side rendering in React](https://reactjs.org/docs/react-dom-server.html)
70-

questions/explain-static-generation-of-react-applications-and-its-benefits/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,3 @@ In this example, the `getStaticProps` function fetches data at build time, and t
7979
- [Next.js documentation on static generation](https://nextjs.org/docs/basic-features/pages#static-generation-recommended)
8080
- [React official documentation](https://reactjs.org/docs/getting-started.html)
8181
- [Static site generators comparison](https://www.staticgen.com/)
82-

questions/explain-the-composition-pattern-in-react/en-US.mdx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ function WelcomeDialog() {
1717
}
1818

1919
function Dialog(props) {
20-
return (
21-
<div className="dialog">
22-
{props.children}
23-
</div>
24-
);
20+
return <div className="dialog">{props.children}</div>;
2521
}
2622
```
2723

@@ -41,11 +37,7 @@ One common way to use composition is by passing components as children to other
4137

4238
```jsx
4339
function Dialog(props) {
44-
return (
45-
<div className="dialog">
46-
{props.children}
47-
</div>
48-
);
40+
return <div className="dialog">{props.children}</div>;
4941
}
5042

5143
function WelcomeDialog() {
@@ -66,23 +58,14 @@ Another way to achieve composition is by passing components as props. This allow
6658
function SplitPane(props) {
6759
return (
6860
<div className="split-pane">
69-
<div className="split-pane-left">
70-
{props.left}
71-
</div>
72-
<div className="split-pane-right">
73-
{props.right}
74-
</div>
61+
<div className="split-pane-left">{props.left}</div>
62+
<div className="split-pane-right">{props.right}</div>
7563
</div>
7664
);
7765
}
7866

7967
function App() {
80-
return (
81-
<SplitPane
82-
left={<Contacts />}
83-
right={<Chat />}
84-
/>
85-
);
68+
return <SplitPane left={<Contacts />} right={<Chat />} />;
8669
}
8770
```
8871

@@ -102,4 +85,3 @@ function App() {
10285
- [React documentation on composition vs inheritance](https://reactjs.org/docs/composition-vs-inheritance.html)
10386
- [React patterns: Composition](https://reactpatterns.com/#composition)
10487
- [Medium article on React composition](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0)
105-

questions/explain-the-presentational-vs-container-component-pattern-in-react/en-US.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ Presentational components are primarily concerned with the UI. They receive data
2626

2727
```jsx
2828
const Button = ({ onClick, label }) => (
29-
<button onClick={onClick}>
30-
{label}
31-
</button>
29+
<button onClick={onClick}>{label}</button>
3230
);
3331
```
3432

@@ -62,12 +60,7 @@ class ButtonContainer extends Component {
6260
};
6361

6462
render() {
65-
return (
66-
<Button
67-
onClick={this.handleClick}
68-
label="Click me"
69-
/>
70-
);
63+
return <Button onClick={this.handleClick} label="Click me" />;
7164
}
7265
}
7366

@@ -89,4 +82,3 @@ export default connect(null, mapDispatchToProps)(ButtonContainer);
8982
- [React documentation on components and props](https://reactjs.org/docs/components-and-props.html)
9083
- [Dan Abramov's article on presentational and container components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0)
9184
- [Redux documentation on presentational and container components](https://redux.js.org/basics/usage-with-react#presentational-and-container-components)
92-

questions/explain-what-happens-when-setstate-is-called-in-react/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ this.setState({ count: this.state.count + 1 }, () => {
5656
- [React documentation on setState](https://reactjs.org/docs/react-component.html#setstate)
5757
- [Understanding setState in React](https://medium.com/@baphemot/understanding-react-setstate-a4640451865b)
5858
- [React's setState explained](https://daveceddia.com/where-fetch-data-componentwillmount-vs-componentdidmount/)
59-

questions/explain-what-react-hydration-is/en-US.mdx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,28 @@ Here's a simple example to illustrate the concept:
2828

2929
1. **Server-side rendering**: The server generates the following HTML:
3030

31-
```html
32-
<div id="root">
33-
<button>Click me</button>
34-
</div>
35-
```
31+
```html
32+
<div id="root">
33+
<button>Click me</button>
34+
</div>
35+
```
3636

3737
2. **Client-side hydration**: When the HTML is sent to the client, React hydrates it with the following code:
3838

39-
```jsx
40-
import React from 'react';
41-
import ReactDOM from 'react-dom';
39+
```jsx
40+
import React from 'react';
41+
import ReactDOM from 'react-dom';
4242

43-
function App() {
44-
const handleClick = () => {
45-
alert('Button clicked!');
46-
};
43+
function App() {
44+
const handleClick = () => {
45+
alert('Button clicked!');
46+
};
4747

48-
return (
49-
<button onClick={handleClick}>Click me</button>
50-
);
51-
}
48+
return <button onClick={handleClick}>Click me</button>;
49+
}
5250

53-
ReactDOM.hydrate(<App />, document.getElementById('root'));
54-
```
51+
ReactDOM.hydrate(<App />, document.getElementById('root'));
52+
```
5553

5654
In this example, the server sends the static HTML with a button to the client. React then hydrates the button by attaching the `onClick` event listener, making it interactive.
5755

@@ -71,4 +69,3 @@ In this example, the server sends the static HTML with a button to the client. R
7169
- [React documentation on hydration](https://reactjs.org/docs/react-dom.html#hydrate)
7270
- [Server-side rendering in React](https://reactjs.org/docs/react-dom-server.html)
7371
- [Next.js documentation on hydration](https://nextjs.org/docs/basic-features/pages#hydration)
74-

questions/how-do-you-debug-react-applications/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,3 @@ function MyComponent() {
9797
- [Error boundaries in React](https://reactjs.org/docs/error-boundaries.html)
9898
- [Using the Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools)
9999
- [Debugging JavaScript](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Debugging)
100-

questions/how-do-you-decide-between-using-react-state-context-and-external-state-managers/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,3 @@ function App() {
162162
- [React documentation on context](https://reactjs.org/docs/context.html)
163163
- [Redux documentation](https://redux.js.org/)
164164
- [MobX documentation](https://mobx.js.org/README.html)
165-

questions/how-do-you-handle-asynchronous-data-loading-in-react-applications/en-US.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,3 @@ function DataFetchingComponent() {
160160
- [Using the Effect Hook](https://reactjs.org/docs/hooks-effect.html)
161161
- [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
162162
- [Handling errors in async functions](https://javascript.info/async-await#error-handling)
163-

0 commit comments

Comments
 (0)