Skip to content

Using same component on different routes #123

@benbonnet

Description

@benbonnet

Hi; went through the issues but could not really find out :/

I have a component that renders a list, this list can be filtered (/items, /items/campaigns, /items/posts, etc...) using react-router. Each 'url filter' should call an api endpoint with specific params and obviously re-render the (same) component listing the correct items after the request

Some code here :

@resolve("items", function(props){
  var url           = "/items/" + props.params.item_type
  return axios.get(url).then((response) => response.data
})
export default class ItemsList extends Component {
  render(){
    const { items } = this.props;
    var list = items.map(function(item){
      return(<h1>{item.title}</h1>)
    })
    return(
      <div className="list">{list}</div>
    )
  }
})

I can get react-resolver return the results when reaching the page server side, but then if i navigate from one to another 'url-filter', nothing happens. I see that componentWillReceivePropsis triggered, but react-resolver won't fetch again the correct data.

I was wondering if it was to be expected, happy to be notified if I was using it wrong (assuming I've been clear enough in the use case I'm exposing above). best

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions