5htp-core 0.4.0-3 → 0.4.0-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.4.0-3",
4
+ "version": "0.4.0-4",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -21,10 +21,12 @@ export default ({ page }: { page: Page }) => {
21
21
  ----------------------------------*/
22
22
  const context = useContext();
23
23
 
24
- const [apiData, setApiData] = React.useState<{[k: string]: any} | null>(
25
- page.data || {}
26
- );
24
+ // Temporary fix: context.page may not be updated at this stage
25
+ // Seems to be the case when we change page, but still same page component with different data
26
+ context.page = page;
27
27
 
28
+ // Bind data
29
+ const [apiData, setApiData] = React.useState<{[k: string]: any} | null>( page.data || {});
28
30
  page.setAllData = setApiData;
29
31
  context.data = apiData;
30
32
 
@@ -105,9 +105,8 @@ export default ({ service: clientRouter }: { service?: ClientRouter }) => {
105
105
  }
106
106
 
107
107
  // Fetch API data to hydrate the page
108
- let newData;
109
108
  try {
110
- newData = await newpage.fetchData();
109
+ await newpage.preRender();
111
110
  } catch (error) {
112
111
  console.error(LogPrefix, "Unable to fetch data:", error);
113
112
  clientRouter.setLoading(false);