Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better API for declaring the fold: <TheFold /> #161

Closed
bartkusa opened this issue May 16, 2016 · 2 comments
Closed

Better API for declaring the fold: <TheFold /> #161

bartkusa opened this issue May 16, 2016 · 2 comments
Assignees
Labels
enhancement New functionality.
Milestone

Comments

@bartkusa
Copy link

bartkusa commented May 16, 2016

Instead of saying "the fold for this page is after the first N elements" (which could change based on middlewares? maybe?), it'd be nice if you could just declare it inline with everything else in JSX. Eg:

getElements() {
    var prefetchConfig = {prefetchUrls:this._getPrefetchURLS()};

    return [
        RootElements.createRootElementWhenResolved(this._emailVerificationBannerStore, <EmailVerificationBanner />),
        RootElements.createRootElementWhenResolved(this._searchAndMerchStore, <SearchAndMerch />),
        <TheFold />
        RootElements.createRootElementWhenResolved(this._listingFeeStore, <MarketingSections />),
        RootElements.createRootElementWhenResolved(this._generalInquiryStore, <GeneralInquiryForm />),
        RootElements.createRootElementWhenResolved(this._eigencitiesStore, <EigencitiesSection />),
        <Prefetch {...prefetchConfig}/>,
    ];
}

(Obviously it doesn't need to really be React or JSX. It could just be require("react-server/TheFold") or something.)

@gigabo
Copy link
Contributor

gigabo commented May 16, 2016

@bartkusa - That's an awesome idea! SO much better than the current API!

@gigabo gigabo added the enhancement New functionality. label May 16, 2016
@gigabo gigabo added this to the v0.3.0 milestone May 16, 2016
@gigabo gigabo self-assigned this May 16, 2016
@lidawang
Copy link
Contributor

This change would make life sooo much easier for the DP!

gigabo added a commit to gigabo/react-server that referenced this issue May 26, 2016
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 (redfin#144)

This closes redfin#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 `<TheFold />` is seen, or we're out of
elements.  So, if unspecified, the entire page is assumed to be above the
fold.
gigabo added a commit to gigabo/react-server that referenced this issue May 26, 2016
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 (redfin#144)

This closes redfin#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 `<TheFold />` is seen, or we're out of
elements.  So, if unspecified, the entire page is assumed to be above the
fold.
davidalber pushed a commit to davidalber/react-server that referenced this issue Jul 24, 2016
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 (redfin#144)

This closes redfin#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 `<TheFold />` is seen, or we're out of
elements.  So, if unspecified, the entire page is assumed to be above the
fold.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality.
Projects
None yet
Development

No branches or pull requests

4 participants