Skip to content

Commit

Permalink
Merge pull request #264 from nimaa77/fix-data-fetching-fix-1
Browse files Browse the repository at this point in the history
Fix data fetching - fix 1
  • Loading branch information
nimaa77 authored Jan 13, 2020
2 parents bba8d5a + 0992f37 commit c9b8a03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class About extends React.Component {
<NavLink to="/">Home</NavLink>
<NavLink to="/about">About</NavLink>
<h1>About</h1>
{this.props.stuff ? this.props.stuff : 'Loading...'}
{this.props.stuff}
</div>
);
}
Expand Down Expand Up @@ -163,7 +163,7 @@ class Detail extends React.Component {
return (
<div>
<h1>Detail</h1>
{this.props.item ? this.props.item : 'Loading...'}
{this.props.item}
<Route
path="/detail/:id/more"
exact
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class About extends React.Component {
}
render() {
console.log(this.props);
return this.props.stuff ? <div>about</div> : null;
return <div>about</div>;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/After.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ class Afterparty extends React.Component<AfterpartyProps, AfterpartyState> {
if (navigated) {
// save the location and data so we can render the old screen
// first we try to use previousLocation and then location from props
this.setState({
previousLocation: this.state.previousLocation || this.props.location,
});
this.setState(prevState => ({
previousLocation: prevState.previousLocation || this.props.location
}));

const { location: currentLocation } = this.props
const { data, match, routes, history, location, staticContext, ...rest } = nextProps;

loadInitialProps(this.props.routes, nextProps.location.pathname, {
Expand All @@ -54,7 +53,8 @@ class Afterparty extends React.Component<AfterpartyProps, AfterpartyState> {
})
.then(({ data }) => {
// if data is not for current location just don't do anything
if (currentLocation !== nextProps.location) {
if (this.props.location !== location) {
// should we save this data in prefetcherCache ?
return
}

Expand Down

0 comments on commit c9b8a03

Please sign in to comment.