This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Export default const in JavaScript and TypeScript | |
const Banana = () => (<div>🍌</div>) | |
export default Banana // Has to be on a separate line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Default exports in JavaScript and TypeScript | |
function Banana() { | |
return <div>🍌</div> | |
} | |
const price = 1.33 | |
// In this example, price is a named export: | |
export { Banana as default, price } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Named exports in JavaScript and TypeScript | |
function Banana() { | |
return <div>🍌</div> | |
} | |
const price = 1.33 | |
export { Banana, price } | |
// These are equivalent to the export syntax above: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ReactNode = | |
| ReactElement | |
| string | |
| number | |
| ReactFragment | |
| ReactPortal | |
| boolean | |
| null | |
| undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ReactNode } from "react" | |
type ILayout = { | |
pageInfo?: { name: string; description: string } | |
children: ReactNode | |
} | |
export default ILayout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ReactNode } from "react" | |
export default interface ILayout { | |
pageInfo?: { name: string; description: string } | |
children: ReactNode | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
interface ILayout { | |
pageInfo?: { name: string; description: string } | |
children: | |
| JSX.Element[] | |
| JSX.Element | |
| React.ReactElement | |
| React.ReactElement[] | |
| string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CardComponent = ({ name, ...props }) => <div>name</div> | |
// That format is equivalent to including the following code: | |
const { name } = props | |
// As in the above example, there could be other stuff in props. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ChildComponent(props) { | |
// There could be other props that we didn't destructure here. | |
const { firstName, lastName } = props | |
return ( | |
<span> | |
{firstName} {lastName} | |
</span> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": [ | |
"prettier" | |
] | |
} |
NewerOlder