ericclemmons / ericclemmons/react-resolver

Using same component on different routes

Open
#123 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.6k
Forks
52
PR merge metrics
No merged PRs in 30d

Description

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(

{item.title}

)
})
return(
{list}

)
}
})
```

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 `componentWillReceiveProps`is 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.