rum 2020-05-02

When I am passing a deps vector to use-effect, do I need to (cljs->js my-vector) ?

No, if deps is not an array Rum transforms it into array with into-array. Might be a good idea to add this into docstring for hooks

👍 1

@amalantony has joined the channel

How can I use an external imported React component in Rum? This is my ns code:

(ns 
  (:require [rum.core :as rum]
            [goog.dom :as dom]
            ["react-moment" :default Moment]))
And this is how I’m trying to render it:
(rum/defc time-component []
  [Moment "1976-04-19T12:59-0500"])
This does not work as expected. This is how the component would look in JSX:
import Moment from 'react-moment';
export default class MyComponent extends React.Component {
    render() {
        return (
            const dateToFormat = '1976-04-19T12:59-0500';
            <Moment>{dateToFormat}</Moment>
        );
    }
}
What’s the Rum equivalent?

@amalantony untested, but I would think:

(rum/defc time-component [] [:div (rum/adapt-class Moment {} "1976-04-19T12:59-0500"]])

@laheadle That works, thank you!

Will adapt-class work for isomorphic server side rendering as well?

Interesting react useWebsocket hook -- could be an alternative to something like sente if your app is structured around hooks already. https://www.npmjs.com/package/react-use-websocket