reactjs - React-router "Cannot GET /*" except for root url -
i willing use react-router application, , trying the example given in doc first, copied below. when go localhost:3000/
, see "app" expected, every other page, such localhost:3000/inbox
returns "cannot /inbox". missing here ?
var = react.createclass({ render: function () { return <h2>about</h2>; }}); var inbox = react.createclass({ render: function () { return <h2>inbox</h2>; }}); var app = react.createclass({ render () { return ( <div><h1>app</h1> <routehandler/> </div> )}}); var routes = ( <route path='/' handler={app}> <route path="about" handler={about}/> <route path="inbox" handler={inbox}/> </route> );
i believe issue making http resource request:
get /inbox http/1.1 host: localhost:3000
but using client-side routing. intending on doing server side rendering too? might need change router location historylocation
instead of hashlocation
(the default).
the location prop of router.run
tells match routes against. if you're not running server side react, believe have use router.hashlocation
(or leave blank).
if not, accessing component wrong way. try using http://localhost:3000/#/inbox
. can take little familiarize react-router worth it!
Comments
Post a Comment