parent
2596091167
commit
4a57c7677c
3 changed files with 45 additions and 0 deletions
@ -0,0 +1,11 @@ |
||||
Inline conditionals in React are expressions that can be used to conditionally render elements. They are useful when you want to render different elements based on a condition. They can be used in JSX by wrapping them in curly braces. Some examples of inline conditionals include the `ternary operator`, logical `&&` operator, and the logical `||` operator. |
||||
|
||||
```js |
||||
<div>{condition ? <span>True</span> : <span>False</span>}</div> |
||||
``` |
||||
|
||||
```js |
||||
<div>{condition && <span>True</span>}</div> |
||||
``` |
||||
|
||||
> Note that you can also use the `if` statement, but it cannot be used inside JSX. It can only be used inside a function body. |
@ -0,0 +1,7 @@ |
||||
You can use React's `React.lazy()` function in conjunction with dynamic `import()` to lazily load a component. This is often combined with `Suspense` to display fallback content while the component is being loaded. |
||||
|
||||
```js |
||||
const MyComponent = React.lazy(() => import('./MyComponent')); |
||||
``` |
||||
|
||||
> Using this pattern requires that the component being lazy loaded is exported as a default export. |
Loading…
Reference in new issue