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
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
How can I use an external imported React component in Rum? This is my ns code:
(ns <http://acme.frontend.app|acme.frontend.app>
(: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?
@amalantony I think so. See here: https://github.com/tonsky/rum/blob/gh-pages/examples/rum/examples/js_components.cljc