Skip to content

Commit 7724df6

Browse files
author
Alex Patterson
committed
show both id and path
1 parent 42620da commit 7724df6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pages/book.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React, { Component } from 'react';
1+
import { withRouter } from 'next/router';
22

3-
export default class Book extends Component {
4-
render() {
5-
return <div>A book</div>;
6-
}
7-
}
3+
const Book = withRouter(props => (
4+
<div>
5+
<p>{`Your id: ${props.router.query.id}` || 'No ID found'}</p>
6+
<p>{`Your path: ${props.router.asPath}` || 'No As Path found'}</p>
7+
</div>
8+
));
9+
export default Book;

0 commit comments

Comments
 (0)