ericclemmons / ericclemmons/react-resolver
Using same component on different routes
- 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(
)
}
})
```
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.