Comments (3)
Quick follow up, this approach got me a bit closer. I use (vec (concat ...)) to package up the options.
(defn Option [props owner]
(om/component
(let [[value display] props]
(dom/option #js {:value value} display))))
(defn Select [props owner]
(om/component
(let [{:keys [label value on-change help placeholder disabled
options default-option default-value]} props
default-value (or default-value "")
default-option (or default-option "Please select")]
(html [:div.form-group
(if label [:label label])
(vec (concat
[:select.form-control {:value (or value default-value)
:placeholder placeholder
:disabled disabled
:on-change on-change}
(if options
(dom/option #js {:value default-value :disabled true} default-option))]
(om/build-all Option options)))
(if help [:p.help-block help])]))))
Note: I still have to use (dom/option...) to avoid two of the errors:
- Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory
- Warning: transferPropsTo is deprecated. See http://fb.me/react-transferpropsto for more information.
from sablono.
Oliver George [email protected] writes:
Quick follow up, this approach got me a bit closer. I use (vec (concat ...)) to package up the options.
(defn Option [props owner] (om/component (let [[value display] props] (dom/option #js {:value value} display)))) (defn Select [props owner] (om/component (let [{:keys [label value on-change help placeholder disabled options default-option default-value]} props default-value (or default-value "") default-option (or default-option "Please select")] (html [:div.form-group (if label [:label label]) (vec (concat [:select.form-control {:value (or value default-value) :placeholder placeholder :disabled disabled :on-change on-change} (if options (dom/option #js {:value default-value :disabled true} default-option))] (om/build-all Option options))) (if help [:p.help-block help])]))))Note: I still have to use (dom/option...) to avoid two of the errors:
- Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory
- Warning: transferPropsTo is deprecated. See http://fb.me/react-transferpropsto for more information.
Reply to this email directly or view it on GitHub:
#48 (comment)
Those are caused by implementation details of Sablono/Om. They will
likely disappear in future releases of those.
Your 'fixed' error messages is caused by the 'list' of members in the
div.form-group: React needs key-attributes so it doesn't have to redraw
the whole list in case the order changes. With `om/build', this is done
with :key or :react-key. Inside components, Om seems to support (or
leak?) :key with a value.
While this is a bit unintuitive given the naming of options to
`om/build', it can be used to work around your warning: Just give every
child-node of div.form-group an unique key like:
[:label {:key "label"}]
[:select.form-control {:key "my-select"}]
etc.
I'm not sure if this is intended in Om: I suspect it would be
better to factor out those elements as their own components and call
`om/build' on them.
from sablono.
Thanks, I'll give that a go.
Might be worth having a wiki page noting common causes/resolutions
associated with react warnings.
On 22 January 2015 at 20:19, Moritz Ulrich [email protected] wrote:
Oliver George [email protected] writes:
Quick follow up, this approach got me a bit closer. I use (vec (concat
...)) to package up the options.(defn Option [props owner] (om/component (let [[value display] props] (dom/option #js {:value value} display)))) (defn Select [props owner] (om/component (let [{:keys [label value on-change help placeholder disabled options default-option default-value]} props default-value (or default-value "") default-option (or default-option "Please select")] (html [:div.form-group (if label [:label label]) (vec (concat [:select.form-control {:value (or value default-value) :placeholder placeholder :disabled disabled :on-change on-change} (if options (dom/option #js {:value default-value :disabled true} default-option))] (om/build-all Option options))) (if help [:p.help-block help])]))))Note: I still have to use (dom/option...) to avoid two of the errors:
- Warning: Something is calling a React component directly. Use a
factory or JSX instead. See: http://fb.me/react-legacyfactory- Warning: transferPropsTo is deprecated. See
http://fb.me/react-transferpropsto for more information.
Reply to this email directly or view it on GitHub:
#48 (comment)Those are caused by implementation details of Sablono/Om. They will
likely disappear in future releases of those.Your 'fixed' error messages is caused by the 'list' of members in the
div.form-group: React needs key-attributes so it doesn't have to redraw
the whole list in case the order changes. With `om/build', this is done
with :key or :react-key. Inside components, Om seems to support (or
leak?) :key with a value.While this is a bit unintuitive given the naming of options to
`om/build', it can be used to work around your warning: Just give every
child-node of div.form-group an unique key like:[:label {:key "label"}]
[:select.form-control {:key "my-select"}]etc.
I'm not sure if this is intended in Om: I suspect it would be
better to factor out those elements as their own components and call
`om/build' on them.—
Reply to this email directly or view it on GitHub
#48 (comment).
from sablono.
Related Issues (20)
- Self-host compat? HOT 1
- Regression: wrapped select doesn't render child elements properly HOT 3
- build-all breaks in simple/advanced compilation HOT 3
- Input not controlled when value and on-change specified. HOT 30
- :style maps kebab-case to CamelCase automatic conversion only works with literals? HOT 4
- Add test for symbol resolution in map keys HOT 1
- How to clear a HTML input element? HOT 4
- Are non-breaking spaces supported? HOT 2
- :npm-deps compat HOT 4
- sablono doens't work in a bootstrapped cljs environment HOT 3
- Now that React 16 has been released can we release a new version of sablono? HOT 13
- `map` inside `for` results in rendered components that don't re-render HOT 1
- Add support for more forms (e.g. `when`) HOT 7
- Add support for directly use other react component HOT 3
- Checkbox inputs don't update "checked" value on rerender HOT 3
- Add cljs.core.Repeat to IInterpreter
- `case` fails when `nil`s are present
- Nested class sequences are not flattened
- js/React is deprecated and makes it hard for folks to use npm react HOT 2
- Docs?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sablono.