7 ms·
It seems interesting. I have one code reading issue, could anyone be so kind to explain it? I read things like: <Subscribe to={[CounterContainer]}> Why are [
by mettamage 9y ago
It seems interesting. I have one code reading issue, could anyone be so kind to explain it?
I read things like: <Subscribe to={[CounterContainer]}>
Why are [ ] needed? And what do [ ] mean here? I thought { } were enough for evaluating code.
- devrelm 9y agoIt looks like Subscribe's `to` prop expects an array. So, `[CounterContainer]` is just an array with a CounterContainer in it. The `{ }` that wrap it are just part of the syntax of passing props. If you wanted to pass an object literal to a prop, you'd have to double-up the curly braces: <div style={{ color: 'white' }} /> And strings can be passed with or without curly braces: // both of these are fine: <div id='foo' /> <div id={'foo'} />
- xatxat 9y agoThey are used to create arrays. You are able to subscribe to multiple containers: <Subscribe to={[CounterContainer, SomeOtherContainer]}> {(counter, someOther) => ()} </Subscribe>
- thaunatos 9y agoI believe that the [] indicate an array.
- mettamage 9y agoAh, right! It just evaluates to JS, fair enough. Thank you all!
- eyelidlessness 9y agoAlmost. It evaluates JS expressions (not statements). It's a minor distinction but trips a lot of people up.