This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-13
Channels
- # babashka (7)
- # babashka-sci-dev (3)
- # beginners (29)
- # biff (16)
- # calva (2)
- # clojars (1)
- # clojure (50)
- # clojure-austin (5)
- # clojure-europe (29)
- # clojure-france (8)
- # clojure-nl (3)
- # clojure-uk (3)
- # clojured (10)
- # clojurescript (19)
- # code-reviews (3)
- # core-async (22)
- # cursive (5)
- # data-science (11)
- # datalevin (1)
- # datomic (10)
- # eastwood (4)
- # helix (4)
- # introduce-yourself (2)
- # jobs (1)
- # jobs-discuss (1)
- # joyride (6)
- # leiningen (4)
- # london-clojurians (2)
- # lsp (82)
- # malli (7)
- # meander (12)
- # minecraft (3)
- # nbb (14)
- # off-topic (52)
- # podcasts-discuss (3)
- # portal (3)
- # re-frame (32)
- # reagent (9)
- # releases (2)
- # shadow-cljs (95)
- # tools-deps (14)
I am trying to render the material-ui Vertical Tabs snippet into clojurescript https://mui.com/material-ui/react-tabs/#vertical-tabs and I am wondering about the correct way to do the prop-types
TabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.number.isRequired,
value: PropTypes.number.isRequired,
};
Is it a with-meta
thing sort of like
(ns verticaltabs
(:require
[prop-types :as PropTypes]
...
(def TabPanel
(with-meta
(fn [{:keys [value index] :as props} & children]
(let [displayed (= value index)]
[:div {:role "tabpanel"
:hidden (not displayed)
:id (str "vertical-tabpanel-" index)
:aria-labelledby (str "vertical-tab-" index)}]
(when displayed
[:> Box {:sx #js{:p 3}}
[:> Typography children]])))
{:propTypes #js {:index (. (. PropTypes -node) -isRequired)
:value (. (. PropTypes -node) -isRequired)
:children (. PropTypes -node)}}))
is there a better way?I understand its a nice-to-have rather than a must
however, it looks like you're using reagent. reagent has a special way of storing it's arguments in React props.
and how would you do that when your component is a function?
using UIx, but very similiar I think
if you inspect your component using react devtools, you can see how props get passed to your component
oh I hadn't thought of that
e.g. for reagent it stores all the arguments in [my-component foo bar baz]
in a single argv
prop
and wraps your function in a special wrapper component that will pull out the argv
prop and then call your function with it
so what I would like to think of as props will always be found in the cljs map at index 1 of the vector (.-argv props) and since react/js PropType does not support an XPath type syntax to point at the specfic keys its a non-starter
and perhaps its not so very useful anywa
that makes sense
thanks