javascript - Nested details route with react-router not rendering -



javascript - Nested details route with react-router not rendering -

i using react-router plugin setup routes want provide 2 routes list/ , list/:id (pretty common) have , what's working this:

<routes> <route handler={app}> <route name="list" handler={listcomponent} collection={new collection()}> </route> </route> </routes>

but struggling "details" route work. tried is:

<routes> <route handler={app}> <route name="list" handler={listcomponent} collection={new collection()}> <route name="list.details" path="list/:id" handler={detailscomponent}> </route> </route> </routes>

first, not working currently, detailscomponent not rendered when accessing list/123 (e.g.)

second, if work: how manager pass 1 model in collection "down" detailscomponent?

thanks in advance!

to reply first question, there 2 issues router code. coincidentally, forwards slash reply both issues:

you need close route components. if write <route> itself, must include closing tag this: <route/>.

you need forwards slash @ start of list path.

so code should like:

<routes> <route handler={app}> <route name="list" handler={listcomponent} collection={new collection()}> <route name="listdetails" path="/list/:id" handler={detailscomponent}/> </route> </route> </routes>

also, clear, route name string identifier. i'm not sure if wrote list.details object accessor model, if so, it's not going think will. changed name listdetails avoid confusion, list.details valid string identifier sense free alter if you'd like.

that resolves code issues in block provided here. without seeing detailscomponent component and/or error messages, can't sure if there other issues.

regarding sec query, solution straightforward (although react-router not have backbone integration might hoping here). however, i'm afraid i'm permitted reply 1 question @ time according stackoverflow rules. i'd happy provide reply if create separate question.

javascript html5 routing reactjs react-router

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -