Listing 12-8: Using the render attribute
Order #4import React from "react";
import {
BrowserRouter as Router,
Route,
Link
} from "react-router-dom";
function ComponentProp(props) {
return (
<>
<Router>
<Link to="/orders/4">Order #4</Link>
<Route path="/orders/:orderid" render={props => (
<h1>Details for order # {props.match.params.orderid}</h1>
)
} />
</Router>
</>
);
}
export default ComponentProp;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.