-
Notifications
You must be signed in to change notification settings - Fork 553
Fix Server Side rendering support #308
Fix Server Side rendering support #308
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@@ -94,6 +100,17 @@ var FixedDataTableBufferedRows = React.createClass({ | |||
} | |||
}, | |||
|
|||
_updateDOMPosition() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of thoughts on this approach:
- Mutating any object is generally bad but in this case we are mutating the DOM node after render which will result in us touching the DOM twice rather than once.
- The other thing is that it wont set any styles for the HTML that gets to the client so before the JS loads the rows will be out of place.
Hey @marduke182, thanks for the PR. The way i was thinking about in the past to solve this was to have some state that tells us we are in the first pass and always render positions with |
Hi @pieterv, My first solution was use the state to store a flag variable, and in componentDidMount change the state to know that the component was mounted. But in the best practice says that never use setState inside componentDidMount. I update the pull request to show you my original solution. Maybe the best way is use Hight Order Component to control the state of initialRender and pass by a property the argument. Thanks for the feedback. |
Hmm i dont think this flag necessarily needs to live on state, since we don't actually want to force a render as a result of changing it, we just need a flag to signify that we are now out of the first render. The down side of this is it will make the render more non-pure, but it wont be to much worse than it already was (since it already relies on global state). so:
Lets also create a wrapper around Thanks for taking this on! |
…or the fancy ones.
f970eec
to
afe6424
Compare
I update the pull request with the final solution. All the modules affected have this change: componentWillMount() {
this._initialRender = true;
}
componentDidMount() {
this._initialRender = false;
} And wrap translateDOMPositionXY, like you said. |
I'm quite interested in this... any chance we can get it merged? |
+1 - Second @tbrd - would love to get this merged |
it would be great to have this pull request merged |
👍 |
2 similar comments
👍 |
👍 |
@marduke182 Thanks for the awesome pull requests, I've merged your fork into some of our code. Though it seems like there a whole bunch of other things that still don't work with SSR. e.g. There a bunch of other small ones I've been band aiding. I wonder if it is time for a fork to really get SSR working? |
Also a good solution to making all rows initially appear for SEO purposes would be great. |
@pieterv Do you have a plan merge this request? |
@tbrd @HillLiu @DenLilleMand @djbobbydrake we've merged the PR for this into our fork at https://github.com/schrodinger/fixed-data-table-2 and should have the fix up on npm within a week. @thomasdavis If you open an issue or PR with the SSR issues you're seeing, we'd appreciate your help getting it stable on our fork. Thanks! |
This resolve issue #44.
I moved all the translateDOMPositionXY calls inside comoponentDidMount and componentDidUpdate.
The site dev server works and my server rendering don`t throw the warning.