React-apollo: Compose not exported?

Created on 29 Aug 2019  路  5Comments  路  Source: apollographql/react-apollo

Failed to compile.

./src/routes/ViewTeam.js
Attempted import error: 'compose' is not exported from 'react-apollo'.

Yet, I'm importing it and it was fine in the prior versions:
import { compose, Query, graphql } from "react-apollo";

Most helpful comment

@tab00
Just tried it inside codesandbox, indeed using import compose from 'lodash.flowright'; works, while import * as compose from 'lodash.flowright'; throws error saying that compose is not a function.

Also if you're not using lodash exported as es-modules import {flowRight as compose} from 'lodash'; works fine as well :)

All 5 comments

It's one of the breaking changes of react-apollo 3.0.

https://github.com/apollographql/react-apollo/blob/master/Changelog.md#breaking-changes.
You should be using compose directly from lodash now.
import * as compose from 'lodash.flowright';

import * as compose from 'lodash.flowright'; doesn't work for me.

In https://github.com/lodash/lodash/blob/master/flowRight.js there is
export default flowRight

So should the import be done like this:
import compose from 'lodash.flowright';
as described in https://stackoverflow.com/questions/39282253/how-can-i-alias-a-default-import-in-javascript?

@tab00
Just tried it inside codesandbox, indeed using import compose from 'lodash.flowright'; works, while import * as compose from 'lodash.flowright'; throws error saying that compose is not a function.

Also if you're not using lodash exported as es-modules import {flowRight as compose} from 'lodash'; works fine as well :)

Thanks for confirming. That means Changelog.md needs to be updated.

Changelog fixed - thanks!

Was this page helpful?
0 / 5 - 0 ratings