From 5a22a2058687e1fcb30e5f80f1d40ddf854356fe Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Thu, 26 May 2016 10:59:24 -0700 Subject: [PATCH 1/3] Expose new convenience function: `navigateTo` This is a much nicer interface for kicking off a client transition. This closes #114. --- packages/react-server-test-pages/entrypoints.js | 4 ++++ .../pages/navigation/navigateTo.js | 17 +++++++++++++++++ packages/react-server/core/common.js | 1 + packages/react-server/core/util/navigateTo.js | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 packages/react-server-test-pages/pages/navigation/navigateTo.js create mode 100644 packages/react-server/core/util/navigateTo.js diff --git a/packages/react-server-test-pages/entrypoints.js b/packages/react-server-test-pages/entrypoints.js index 6e3ead569..e9c534a72 100644 --- a/packages/react-server-test-pages/entrypoints.js +++ b/packages/react-server-test-pages/entrypoints.js @@ -33,6 +33,10 @@ module.exports = { entry: "/navigation/data-bundle-cache", description: "Data bundle cache", }, + NavigateTo: { + entry: "/navigation/navigateTo", + description: "Navigate using `navigateTo()`", + }, ErrorLogs: { entry: "/error/logs", description: "Generate errors in the logs", diff --git a/packages/react-server-test-pages/pages/navigation/navigateTo.js b/packages/react-server-test-pages/pages/navigation/navigateTo.js new file mode 100644 index 000000000..9eb6e7991 --- /dev/null +++ b/packages/react-server-test-pages/pages/navigation/navigateTo.js @@ -0,0 +1,17 @@ +import {navigateTo} from "react-server"; + +const go = page => navigateTo( + `/navigation/navigateTo?cur=${page}`, + {reuseDom: true} +) + +const Nav = ({cur}) =>
go(cur+1)}> +
Current page: {cur}
+
Click for next page
+
+ +export default class NavigateToPage { + getElements() { + return