0

So I have a React component that uses the google-maps-react package along with redux

Now the thing is that I need to export connect() and the GoogleApiWrapper together. I googled a bit and found someone who did it like this :

export default connect(
  mapStateToProps,
  { saveMapCoords }
)(
  GoogleApiWrapper({
    apiKey: 'AIzaSyA5EqRGJ-YR-2ZCGxThhtFZKwNBy6wk73c'
  })
)(Maps)

Where Maps is the class name.

Unfortunately I get this error : TypeError: Object(...)(...)(...) is not a function

This is returned from the line GoogleApiWrapper

Does anyone know why this happens? They work separately but not together

2
  • 1
    It seems you are misplacing one bracket: ` export default connect( mapStateToProps, { saveMapCoords } )( GoogleApiWrapper({ apiKey: 'AIzaSyA5EqRGJ-YR-2ZCGxThhtFZKwNBy6wk73c' }) )(Maps)) ` Commented Jul 9, 2019 at 11:12
  • This is actually the same as I wrote above but with an extra bracket at the end, and the bracket at the end gives me a compiling error that says that there is a bracket that shouldn't be there. Commented Jul 9, 2019 at 11:17

1 Answer 1

2

You're closing a bracket before. The GoogleApiWrapper

GoogleApiWrapper({
  apiKey: (YOUR_GOOGLE_API_KEY_GOES_HERE)
})(MapContainer)

is a HOC that'll return a new component that you'll then pass in the connect.

Try this

export default connect(
    mapStateToProps,
    { saveMapCoords }
)(
    GoogleApiWrapper({
        apiKey: "AIzaSyA5EqRGJ-YR-2ZCGxThhtFZKwNBy6wk73c"
    })(Maps)
)
Sign up to request clarification or add additional context in comments.

2 Comments

Oh I see, so I wasn't that far away from what I wanted. Thanks for correcting that.
Glad it helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.