Created
October 20, 2019 05:35
-
-
Save raibima/5114eadd627e929d28db934a5d328bd9 to your computer and use it in GitHub Desktop.
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 component with Hooks | |
| * @see: https://reactjs.org/docs/hooks-intro.html | |
| */ | |
| import { useRouter } from "next/router"; | |
| function FunctionComponentPage() { | |
| const router = useRouter(); | |
| return <h1>{`ID: ${router.query.id}`}</h1>; | |
| } | |
| export default FunctionComponentPage; | |
| /** | |
| * Class component with Higher-Order Components | |
| * @see: https://reactjs.org/docs/higher-order-components.html | |
| */ | |
| import { withRouter } from 'next/router'; | |
| class ClassComponentPage extends React.Component { | |
| render() { | |
| const { router } = this.props; | |
| return <h1>{`ID: ${router.query.id}`}</h1>; | |
| } | |
| } | |
| export default withRouter(ClassComponentPage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment