Closed LucyHut closed 7 years ago
Hi @LucyHut this is quite some hard work! Really appreciate it.
I noticed an issue that I suspect might have to do with how routing is setup here. Here is what I tried:
Issues with routing:
<IndexRedirect>
for path "posts" should probably be <IndexRoute>
. The posts index page is about a list of items, so its data needs and display needs are different from regular post page which focuses on a single item. <IndexRoute>
allows you to specify a component.<Route component={Wordpress} path='posts' >
is designed for specifying a shared wrapper like component used for displaying post/ and post/:postId . Instead of the Wordpress component, the component that goes in there would have a render function like:render() {
return (
<div>
{/* some shared display, such as a header */}
{this.props.children}
{/* some shared display, such as a footer */}
</div>
);
}
Here is an example similar to what you want to do in the React-router tutorial https://github.com/ReactTraining/react-router/blob/v2.8.1/docs/Introduction.md#with-react-router
Please let me know if you have questions
@sibyl229 , thank so much for the feedback --- I also noticed the issue and suspected the routing. I will review the link and give it another try 👍
@sibyl229, after few research it looks like IndexRoute abstraction is no longer supported starting react-router 4.0 - so I'm exploring different options .
Hi @LucyHut the version we are currently at AGR using is 2.8.1 https://github.com/alliance-genome/agr/blob/development/webapp/package.json#L26
react router 4.0 is very different and not backward compatible. So it will probably have a more widespread impact on the codebase. If we need to upgrade, it's probably good to discuss among the group first, and/or try it in another branch.
@sibyl229, I went with the news and posts having the "posts" route and the pages have the initial wordpress route. It seems to be working fine now.
Still work in progress but it's worth pulling in the following new features.