reactjs - React Router nested Switch component, child component won't render via direct link -


i have app.js rendering per code below:

const root = () => {     return (         <browserrouter>             <div>                 <switch>                     <route path="/" component={app} />                 </switch>             </div>         </browserrouter>     ); }; 

inside app.js have anested route product.js

<header />             <switch>                 {results &&                     results[searchkey] &&                     <route                         exact                         path="/product/:id"                         name="product"                         component={props => <product product={product} searchterm={searchterm} {...props} />}                     />}             </switch> <footer /> 

product renders if click through app component '/' url.

but if try access products component directly via url '/product/123456' nothing happens, , componentdidmount not run.

any advice please?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -