From 971b8ced560f93e3044a0ee06baff9fe4cb70fa9 Mon Sep 17 00:00:00 2001 From: Bo Borgerson Date: Wed, 25 May 2016 17:12:21 -0700 Subject: [PATCH 1/2] Add new component: `` This replaces the `getAboveTheFoldCount()` page method, which is awful: - It's separate from the elements themselves, so even remembering to update it can be a challenge. - If the number of root elements above the fold varies, then duplicative logic may be required to determine the count. - Middleware that inserts elements must remember to _increment_ it. - It has non-obvious behavior when root containers are used above the fold (#144) This closes #161 where @bartkusa proposed this _much_ nicer interface. This is a breaking change. The _default_ was previously to wake up the client controller after the _first_ element. With this change the client controller isn't bootstrapped until either `` is seen, or we're out of elements. So, if unspecified, the entire page is assumed to be above the fold. --- docs/understanding-rendering.md | 7 ++- docs/writing-pages.md | 1 - .../pages/data/delay.js | 7 ++- .../pages/root/aboveTheFold.js | 22 ++++----- .../react-server/core/ClientController.js | 18 +++---- packages/react-server/core/common.js | 1 + .../core/components/RootElement.js | 6 ++- .../react-server/core/components/TheFold.js | 19 ++++++++ .../react-server/core/renderMiddleware.js | 47 ++++++++++++------- packages/react-server/core/util/PageUtil.js | 3 +- 10 files changed, 83 insertions(+), 48 deletions(-) create mode 100644 packages/react-server/core/components/TheFold.js diff --git a/docs/understanding-rendering.md b/docs/understanding-rendering.md index ae13b7b4b..ff4fa8bbb 100644 --- a/docs/understanding-rendering.md +++ b/docs/understanding-rendering.md @@ -28,6 +28,7 @@ getElements() { +