From 95144f8b07978f8b57b156a669d9cb288cf0b7aa Mon Sep 17 00:00:00 2001 From: Nima Arefi Date: Tue, 24 Dec 2019 20:29:35 +0330 Subject: [PATCH 1/4] fix AfterParty --- src/After.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/After.tsx b/src/After.tsx index 6e191e29..3fdbfe96 100644 --- a/src/After.tsx +++ b/src/After.tsx @@ -40,11 +40,10 @@ class Afterparty extends React.Component { 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, { @@ -54,7 +53,8 @@ class Afterparty extends React.Component { }) .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 } From 619bbca775928e6a410adc683d4773094a75607f Mon Sep 17 00:00:00 2001 From: Nima Arefi Date: Tue, 24 Dec 2019 20:29:45 +0330 Subject: [PATCH 2/4] update docs --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 35d43e6a..c73e9bb7 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,23 @@ Next.js is awesome. However, its routing system isn't for me. IMHO React Router - [After.js](#afterjs) - - [Project Goals / Philosophy / Requirements](#project-goals--philosophy--requirements) - - [Getting Started with After.js](#getting-started-with-afterjs) - - [Razzle Quickstart](#razzle-quickstart) - - [Data Fetching](#data-fetching) - - [`getInitialProps: (ctx) => Data`](#getinitialprops-ctx--data) - - [Injected Page Props](#injected-page-props) - - [Routing](#routing) - - [Parameterized Routing](#parameterized-routing) - - [Client Only Data and Routing](#client-only-data-and-routing) - - [Dynamic 404 and Redirects](#dynamic-404-and-redirects) - - [Dynamic 404](#dynamic-404) - - [Redirect](#redirect) - - [Code Splitting](#code-splitting) - - [Custom ``](#custom-document) - - [Custom/Async Rendering](#customasync-rendering) - - [Author](#author) - - [Inspiration](#inspiration) + - [Project Goals / Philosophy / Requirements](#project-goals--philosophy--requirements) + - [Getting Started with After.js](#getting-started-with-afterjs) + - [Razzle Quickstart](#razzle-quickstart) + - [Data Fetching](#data-fetching) + - [getInitialProps: (ctx) => Data](#getinitialprops-ctx-gt-data) + - [Injected Page Props](#injected-page-props) + - [Routing](#routing) + - [Parameterized Routing](#parameterized-routing) + - [Client Only Data and Routing](#client-only-data-and-routing) + - [Dynamic 404 and Redirects](#dynamic-404-and-redirects) + - [Dynamic 404](#dynamic-404) + - [Redirect](#redirect) + - [Code Splitting](#code-splitting) + - [Custom <Document>](#custom-ltdocumentgt) + - [Custom/Async Rendering](#customasync-rendering) + - [Author](#author) + - [Inspiration](#inspiration) @@ -84,7 +84,7 @@ class About extends React.Component { Home About

About

- {this.props.stuff ? this.props.stuff : 'Loading...'} + {this.props.stuff} ); } @@ -163,7 +163,7 @@ class Detail extends React.Component { return (

Detail

- {this.props.item ? this.props.item : 'Loading...'} + {this.props.item} Date: Tue, 24 Dec 2019 20:29:56 +0330 Subject: [PATCH 3/4] update examples --- examples/basic/src/About.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic/src/About.js b/examples/basic/src/About.js index a0465d90..f47eacdc 100644 --- a/examples/basic/src/About.js +++ b/examples/basic/src/About.js @@ -6,7 +6,7 @@ class About extends React.Component { } render() { console.log(this.props); - return this.props.stuff ?
about
: null; + return
about
; } } From 0992f37560b3d4adaae6cacfac3b77e911de8935 Mon Sep 17 00:00:00 2001 From: Nima Arefi Date: Tue, 24 Dec 2019 20:45:12 +0330 Subject: [PATCH 4/4] UPDATE README.md --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c73e9bb7..92890d4d 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,23 @@ Next.js is awesome. However, its routing system isn't for me. IMHO React Router - [After.js](#afterjs) - - [Project Goals / Philosophy / Requirements](#project-goals--philosophy--requirements) - - [Getting Started with After.js](#getting-started-with-afterjs) - - [Razzle Quickstart](#razzle-quickstart) - - [Data Fetching](#data-fetching) - - [getInitialProps: (ctx) => Data](#getinitialprops-ctx-gt-data) - - [Injected Page Props](#injected-page-props) - - [Routing](#routing) - - [Parameterized Routing](#parameterized-routing) - - [Client Only Data and Routing](#client-only-data-and-routing) - - [Dynamic 404 and Redirects](#dynamic-404-and-redirects) - - [Dynamic 404](#dynamic-404) - - [Redirect](#redirect) - - [Code Splitting](#code-splitting) - - [Custom <Document>](#custom-ltdocumentgt) - - [Custom/Async Rendering](#customasync-rendering) - - [Author](#author) - - [Inspiration](#inspiration) + - [Project Goals / Philosophy / Requirements](#project-goals--philosophy--requirements) + - [Getting Started with After.js](#getting-started-with-afterjs) + - [Razzle Quickstart](#razzle-quickstart) + - [Data Fetching](#data-fetching) + - [`getInitialProps: (ctx) => Data`](#getinitialprops-ctx--data) + - [Injected Page Props](#injected-page-props) + - [Routing](#routing) + - [Parameterized Routing](#parameterized-routing) + - [Client Only Data and Routing](#client-only-data-and-routing) + - [Dynamic 404 and Redirects](#dynamic-404-and-redirects) + - [Dynamic 404](#dynamic-404) + - [Redirect](#redirect) + - [Code Splitting](#code-splitting) + - [Custom ``](#custom-document) + - [Custom/Async Rendering](#customasync-rendering) + - [Author](#author) + - [Inspiration](#inspiration)