Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Restore getDataFromTree(rootElement, rootContext) API. #2586

Merged
merged 3 commits into from
Nov 14, 2018

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Nov 12, 2018

In [email protected], the rootContext parameter was replaced by the custom renderFunction parameter, which was a breaking change: #2533 (comment)

This commit restores the previous API, while providing an alternative API that is more flexible and more accurately named: getMarkupFromTree

If you want to specify a custom rendering function, you should now use getMarkupFromTree instead of getDataFromTree:

import { getMarkupFromTree } from "react-apollo";
import { renderToString } from "react-dom/server";

getMarkupFromTree({
  tree: <App/>,
  // optional; defaults to {}
  context: { ... },
  // optional; defaults to renderToStaticMarkup
  renderFunction: renderToString,
}).then(markup => {
  // Use the markup returned by the final rendering...
});

Hopefully, since [email protected] was never assigned the latest tag on npm, we can push this change without another minor version bump (likely 2.3.1).

cc @evenchange4 @hwillson

In [email protected], the rootContext parameter was replaced by the
custom renderFunction parameter, which was a breaking change:
#2533 (comment)

This commit restores the previous API, while providing an alternative API
that is more flexible and more accurately named: getMarkupFromTree.

If you want to specify a custom rendering function, you should now use
getMarkupFromTree instead of getDataFromTree:

  import { getMarkupFromTree } from "react-apollo";
  import { renderToString } from "react-dom/server";

  getMarkupFromTree({
    tree: <App/>,
    // optional; defaults to {}
    context: { ... },
    // optional; defaults to renderToStaticMarkup
    renderFunction: renderToString,
  }).then(markup => {
    // Use the markup returned by the final rendering...
  });

Hopefully, since [email protected] was never assigned the `latest` tag on
npm, we can push this change without another minor version bump.

cc @evenchange4 @hwillson
@benjamn benjamn merged commit 99a846f into master Nov 14, 2018
@benjamn benjamn deleted the fix-getDataFromTree-backwards-compatibility branch November 14, 2018 19:11
@csantos1113
Copy link

Hi @benjamn - thanks for your hard work on the SSR support. Are you publishing this version soon to npm registry?

@benjamn
Copy link
Member Author

benjamn commented Nov 15, 2018

@csantos1113 It's published now as version 2.3.1, though it's still using the next tag instead of latest.

@csantos1113
Copy link

csantos1113 commented Nov 15, 2018

@benjamn - thank you!


Just FYI, seems that you also pointed latest to be 2.3.1.
See: https://www.npmjs.com/package/react-apollo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants