-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from gigabo/the-fold
Add new component: `<TheFold />`
- Loading branch information
Showing
10 changed files
with
85 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
packages/react-server-test-pages/pages/root/aboveTheFold.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import {ReactServerAgent, RootContainer, RootElement} from "react-server"; // eslint-disable-line | ||
|
||
// TODO: when we implement <TheFold/> (https://github.com/redfin/react-server/issues/161), | ||
// update this test page to use the new API | ||
import { | ||
ReactServerAgent, | ||
RootContainer, | ||
RootElement, | ||
TheFold, | ||
} from "react-server"; | ||
|
||
export default class RootWhenPage { | ||
handleRoute(next) { | ||
this.data = ReactServerAgent.get('/data/delay?ms=200'); | ||
this.data = ReactServerAgent.get('/data/delay?ms=200&big=10000') | ||
.then(res => res.body); | ||
return next(); | ||
} | ||
getElements() { | ||
return [ | ||
<RootContainer> | ||
<RootContainer when={this.data}> | ||
<div>One</div> | ||
</RootContainer>, | ||
<RootElement when={this.data}><div>Two</div></RootElement>, | ||
<RootContainer> | ||
<div>Three - there should be script tags starting from right after me b/c my getAboveTheFoldCount is 3!</div> | ||
<div>Three - there should be script tags starting from right after me.</div> | ||
<TheFold /> | ||
<RootElement when={this.data}><div>Four</div></RootElement> | ||
</RootContainer>, | ||
<div>Five</div>, | ||
] | ||
} | ||
|
||
getAboveTheFoldCount() { | ||
return 3; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Component} from "react"; | ||
|
||
export default class TheFold extends Component { | ||
render() { | ||
throw new Error("Something went wrong. Trying to render the fold..."); | ||
} | ||
} | ||
|
||
TheFold.defaultProps = { | ||
_isTheFold: true, | ||
} | ||
|
||
export function isTheFold(element) { | ||
return element && element.props && element.props._isTheFold; | ||
} | ||
|
||
export function markTheFold() { | ||
return {isTheFold:true}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters