This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-15
Channels
- # announcements (1)
- # beginners (101)
- # boot (13)
- # cider (38)
- # cljdoc (10)
- # cljs-dev (37)
- # cljsrn (6)
- # clojure (74)
- # clojure-dev (8)
- # clojure-europe (3)
- # clojure-italy (36)
- # clojure-losangeles (2)
- # clojure-nl (5)
- # clojure-spec (15)
- # clojure-uk (49)
- # clojuredesign-podcast (2)
- # clojurescript (52)
- # cursive (6)
- # datomic (19)
- # fulcro (35)
- # graalvm (16)
- # graphql (4)
- # kaocha (1)
- # leiningen (26)
- # luminus (3)
- # re-frame (10)
- # reagent (14)
- # ring-swagger (37)
- # rum (2)
- # schema (4)
- # shadow-cljs (148)
- # spacemacs (13)
- # specter (1)
- # sql (46)
- # tools-deps (3)
- # vim (4)
hey, what's the meaning of #object[Object [object Object]]
? I println
some Vars
and it output this.
hey, is there anyone knowing the meaning of following code snippet?
(defprotocol IReset
"Protocol for adding resetting functionality."
(-reset! [o new-value]
"Sets the value of o to new-value."))
I can't find anythings about defprotocol
with -methodname
and have not this
in parameters
.The first parameter in the protocol definition need not be called this
, but that is what it is, I am pretty sure.
It might need to be called this
when inside of a deftype
form, for example, to define the implementation of such a protocol method. The parameter names used when the implementation is given need not match the ones used inside defprotocol
how would you write JS like this in CLJS?
<motion.div />
(motion.div )
?
(.createElement js/React (.-div js/motion))
but I assume you are using React wrapper in cljs?
thanks for the response :thumbsup: . Yes, I'm using a React wrapper. It should allow me to use motion
directly, but the "dot div" .div
is causing it to fail, I think.
@jakobssonrobin which one are you using? Reagent?
Hey, how do you use a react UI component in ClojureScript? It's state
and some method props
really tricky to dispose.
Could you explain a bit more? It’s not clear what is your question about
I want use some bare React UI Component in ClojureScript. But they rerender depend state
update. Are there some good ways to use or update the state
?
Reagent can only wrap Component, but some of them has their own methods to update, these methods use state
to reserve state props as default. But I have no way to deal with it.
@roman01la @jakobssonrobin I have seen you talk about react component, do you know this problem?😁
@ULZE0PA2K I don't know reagent unfortunately.
ah ok, not familiar with it
but in Reagent there’s interop syntax for js components [:> js/motion.div props]
ah, cheers. thanks
@roman01la But some bare React bare Component rerender when it self state
flush.
For example, a UI from react-native-elements, the onChangeText only need a state
to rerender a Component.
import { SearchBar } from 'react-native-elements';
export default class App extends React.Component {
state = {
search: '',
};
updateSearch = search => {
this.setState({ search });
};
render() {
const { search } = this.state;
return (
<SearchBar
placeholder="Type Here..."
onChangeText={this.updateSearch}
value={search}
/>
);
}
}
Does anyone have experience using Material UI in Reagent? I’m trying to use ThemeProvider but I get the following error.
TypeError: _styles.withStyles is not a function
Even though I’m not using withStyles.
Here’s my code:
Based off of this: https://codesandbox.io/s/kd7lq
@jakobssonrobin As a general rule, in Fulcro you want to wrap the JS library classes in a ui-factory. See http://book.fulcrologic.com/fulcro3/#_using_javascript_react_components - Also, there is a #fulcro channel on Slack where you may want to ask in the future.
got it working by doing this (def motion-div (create-react-element (.-div motion)))
@kevin.van.rooijen the code you posted is using react hooks (ie. useStyles
). that is not supported by reagent. can't tell if you are using that or not.
@kevin.van.rooijen Due to the lack of react hooks in reagent I made the switch over to hx
.
If you want to stay in reagent the only way I managed to make hooks of third party libraries work was to opt-out of reagent and opt-in again:
(defn Component []
(let [[ob setOb] (react/setState #js {})]
(reagent/as-element [:div ..... ])
And then use it as:
[:> Component ...]
And I'm not sure how trustworthy that code is in the enddo you miss re-frame with hx
? I am not familiar with hx
at all, does it have something comparable to re-frame for reagent?
Atm I don't use re-frame (yet?) and I'm not sure if I'll feel the need for it eventually.
There is an example by the creator of hx
though which maps the RAtom used by re-frame to a react hook though so you can subscribe to re-frame through react hooks.
The one downside I see is that it pulls in the whole of reagent just for the RAtom
hx
is nothing else than a small wrapper around react and doesn't provide all that much itself. It replaces reagent to some degree but doesn't add state handling logic itself like reagent does. hx
relies on the new react hooks for that.
https://github.com/Lokeh/hooks-demo/blob/master/src/hooks_demo/hooks.cljs
Here is an example of a <-sub
hook implementation which subscribes to re-frame - which can be used in hx
to access re-frame state
It works for local state, but once you have to manage workflow of events, re-frame is a great tool.
how does reagent trigger react component’s re-render? I know that reagent keep a deref list of components to triggger re-render upon ratom update, but they are not react component’s props or state, how does reagent notify react which components did update?
I just tried copy the html, paste it as the first page. it open instantly, however, when javascript ready, this is a whole re-render of whole page which cause a flicker.
Hi :spock-hand: . I really need help integrating reagent with the current React/TypeScript codebase.
Excuse me I didn’t know there was an #reagent. Shared the question https://clojurians.slack.com/archives/C0620C0C8/p1565895519303800
Regarding questions on all numbers in JS, and thus ClojureScript, being floating point, I found in ECMA-252 standard the section "6.1.6 The Number Type" that goes into significant detail on this. Basically all Number type values are 64-bit double precision IEEE 754 floating point numbers. That spec even helpfully points out that all integers from -2^53 to +2^53 an be represented exactly in this format (I might be off by on there on the endpoints of that range). Cool. That is a pretty reasonable sized exact range for integer operations.