This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-10
Channels
- # announcements (1)
- # babashka (18)
- # beginners (122)
- # calva (18)
- # cider (3)
- # cljs-dev (2)
- # cljsrn (3)
- # clojure (102)
- # clojure-europe (15)
- # clojure-france (2)
- # clojure-nl (1)
- # clojure-portugal (1)
- # clojure-spec (3)
- # clojure-uk (8)
- # clojurescript (46)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (2)
- # cursive (15)
- # datalog (13)
- # datomic (18)
- # emacs (4)
- # fulcro (8)
- # helix (8)
- # instaparse (1)
- # introduce-yourself (2)
- # jobs (4)
- # leiningen (23)
- # lsp (26)
- # malli (21)
- # off-topic (34)
- # pedestal (21)
- # polylith (6)
- # reitit (5)
- # remote-jobs (3)
- # schema (1)
- # sci (8)
- # shadow-cljs (8)
- # spacemacs (3)
- # sql (30)
- # testing (31)
- # tools-deps (21)
- # vim (25)
- # xtdb (8)
How would I distinguish between a function defined in JS and a function defined in CLJS, from CLJS?
In one case, I'd like to do some clj->js transformations and in other case do nothing.
maybe you can test (if (coll? x) (clj->js x) x)
should be safe always to call js->clj
Hey, can anyone recommend a good table library? (I am new to reagent and am not sure if the new hook approach in react-table v7 is compatible)
I meant using the hooks within reagent, I am not sure how to approach it. For instance react tables v7 exposes the useTable
hook
I meant that as well: https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#hooks
Yeah that is a great example on creating a hook within the component. I am battling to find an example of re-using a pluggable hook another library exposes
Sure https://react-table.tanstack.com/docs/examples/basic In particular:
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = useTable({
columns,
data,
})
It will simply be
(let [^js table (useTable #js {:columns columns, :data data})
get-table-props (.-getTableProps table)
...]
...)
So at the end of the day it's more of a question of CLJS-JS interop rather than what Reagent supports.Of course, you don't need to bind every field from the resulting object to a separate name - you can just use them via interop as well, like (.getTableProps table)
instead of (let [f (.-getTableProps table)] (f))
.
Ah thanks! Yeah sorry being completely new to CLJS I am not sure which are the parts that are working and which aren't still making my way through all of the courses. Thank you for being such a great help! This really was the last hurdle that was blocking me
Sure thing, and no need to be sorry - we all start somewhere. A few things, just in case: • There's the #beginners channel that might come in handy, especially if your question is more CLJ oriented • Don't work with multiple new things at a time - try to get comfortable with them one by one. CLJS-JS interop should be a good first thing, if you aren't comfortable with it yet.
Great thanks 🙂
(crossposted from #uix in the hope of gaining more traction...) I am experimenting with UIx (https://github.com/roman01la/uix) and MaterialUI (https://material-ui.com) and ShadowCljs I am reimplementing the Sliding Dialog from https://material-ui.com/components/dialogs/#transitions and I hit a roadblock with the
const Transition = React.forwardRef(function Transition(props, ref) {
bit
Does UIx have an idiomatic way to handle react/forwardRef
?
Seems like because forwardRef creates a render function that takes an extra parameter for the ref
and uix.core.alpha/as-element
only ever passes a single props parameters
then there is a mismatch
I can cajole it into working if I bypass UIx thus
(defn Transition
"Ive not found a uix idiomatic way to handle the extra parameter of forwardRef"
[]
(r/forwardRef (fn [props ref]
(set! (.-ref props) ref)
(set! (.-direction props) "up")
(r/createElement Slide/default props))))
but I'm wondering if there is a more harmonious way to achieve this....
I dont completely grok how the forward Ref fits in to the bigger React/Component picture, so it seems quite likely I have missed something...
Here is the gist
https://gist.github.com/hammonba/c01431cbac4cc852efad408cf8dc0c90TL;DR when using React class components, refs could be used to get a ref to a DOM node OR they could be used to get access to the instance of a class. you typically didn't want to forward refs when you passed along props to another element in the latter case. So React removes the prop "ref"
before it passes the props object to your component's render by default
Since we live in an age where most components are functions now, we don't have need to get access to a class instance (since there isn't one) so it might make more sense to pass along refs, but they haven't made it the default because it might break backwards compatibility.
UIx can get around this though because UIx doesn't pass props down like normal. So there's no "ref"
key for React to remove when you pass in [transition {:ref ref}]
ah, I do see that you are not the one to render your transition
component tho. so I think what you posted is actually the best way to do this. I'm not intimately familiar with how UIx as-react
works with refs
Non-technical question for you guys: I needed to format an integer into a string with commas and I know clojurescript does not have a format function so I made a quick function to do so. Where should I share it so that somebody can just look up on google "format integer clojurescript" and use the code? Github Gist? Might save some people, especially beginners, some time...
The "simplest" way is to make a github repo with a basic deps.edn setup, then have a thing they can copy paste from the readme to include the git dependency
The second simplest way is to do the same with deps or lein and have it published on jitpack
what does SEO mean?
(.toLocaleString 1234556677534.34)
results in "1,234,556,677,534.34"
. There might be a built-in that serves your purposes
wow haha ok looks like the functionality's already there. wish it was easier to locate
"search engine optimization" - how to appear when someone googles "format integer clojurescript"
ahhh ok thank you
i found that because i first checked to see if the goog library had something. it did not so i then just googled it
Ok you googled for a js function bc you knew it would be interoperable right?
not sure i follow. i looked at js functions because you can always use interop with the host language
Gotcha gotcha thank you!
there is also https://google.github.io/closure-library/api/goog.i18n.NumberFormat.html
Perfect thx
TL;DR when using React class components, refs could be used to get a ref to a DOM node OR they could be used to get access to the instance of a class. you typically didn't want to forward refs when you passed along props to another element in the latter case. So React removes the prop "ref"
before it passes the props object to your component's render by default
Since we live in an age where most components are functions now, we don't have need to get access to a class instance (since there isn't one) so it might make more sense to pass along refs, but they haven't made it the default because it might break backwards compatibility.
UIx can get around this though because UIx doesn't pass props down like normal. So there's no "ref"
key for React to remove when you pass in [transition {:ref ref}]
Do y'all know why clojure.string/split functions differently in clojure than clojurescript? For example: In Clojure, (clojure.string/split "3456" #"") produces ["3" "4" "5" "6"], vs in ClojureScript it produces ["" "3" "4" "5" "6"]
regexes in Clojure and ClojureScript use the host implementations. Those will have differences
ahhh ok