This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-27
Channels
- # beginners (80)
- # boot (5)
- # cider (4)
- # cljsrn (3)
- # clojure (83)
- # clojure-russia (1)
- # clojure-spec (15)
- # clojurescript (20)
- # community-development (8)
- # cursive (6)
- # emacs (5)
- # fulcro (14)
- # hoplon (71)
- # off-topic (6)
- # om (2)
- # onyx (33)
- # parinfer (3)
- # re-frame (21)
- # reagent (20)
- # spacemacs (2)
- # specter (4)
- # vim (8)
Hi all, I'm trying re-use the components from react-google-maps
and implement the simple map example from the doc: https://tomchentw.github.io/react-google-maps/basics/simple-map
However, I'm a blocked by the withGoogleMap
Higher-Order Component (HOC) that wraps the GoogleMap
component. I have tried to adapt the classes with Reagent and use them as follow:
(def GoogleMap (adapt-react-class js/ReactGoogleMaps.GoogleMap))
(def withGoogleMap (adapt-react-class js/ReactGoogleMaps.withGoogleMap))
(defn Map [props]
[withGoogleMap
[GoogleMap props]])
in lieu of the following Javascript:
const Map = withGoogleMap(props => (
<GoogleMap
{... props}
>
</GoogleMap>
));
Without success. (I get the following error withGoogleMap(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
).
Not being very fluent in Javascript and Clojurescript interop, I might have missed something.I think withGoogleMap is just a function that returns a component given some input, not a component itself.
So I'm guessing you should call it directly with parens instead of angle brackets, and lose the adapt-react-class
in your withGoogleMap def.
This is what I thought first but then I got the error cannot call a class as a function
as withGoogleMap
type is an object[Container]
@lepistane that recipe only shows how to display the highchart when the component mounts. Try adding a :component-did-update lifecycle (assuming that your 'get results' button will swap! something in your ratom that will then in turn update your component)
i was thinking to get something like this working (sorry i dont know very much react)
get resutlls > sends request, gets data from server> handler puts that in reagent.session > i make component that works like if there is data in session show charts
@gadfly361 thank you!!