Since when does Reason have JSX?
What should go into JSX 2.0?
31–40 of 102 posts
Re: What should go into JSX 2.0?
#32I wish it could be possible to write this: const animal = "cat"; equivalent to:
Re: What should go into JSX 2.0?
#33Earlier quoted context omitted.
I think ternary expression are rather ok here, though not perfect: {cond1 && cond2 ? foo : null }
And you can inline if-statements with an IIFE when you need a little more space: {(() => { if (cond1 && cond2) return foo else ... })()} Though it makes GitHub think it's a Clojure file.
{(() => {
})()}
Honestly I can't decide if I think this is ugly or beautiful. It's like the buffalo buffalo of JS.Re: What should go into JSX 2.0?
#34I like how the if proposal is down voted, probably because it's mentioning Angular. Conditional rendering in React is not always very clean. Most codebases end up resorting with something similar to this in a container to show a spinner while data is loading and rendering it when done. Problem is that the inner component will still be parsed and fail with cannot read property person of undefined. Yes, you can do this…
It's the extreme fanboyism there! Wrapping every component that has ` if` attribute with an `if` statement should not result into that: foo // results to if (cond1 && cond2) { return React.createElement('div', null, React.createElement('div', null, 'foo') ); } I'm not sure why this is bad? Because it's looking like Angular?!!
translates to
React.createElement('div', {if: })
This is bad because createElement always gets execute, whether the if expression evaluated to true or false. Changing this semantic would be messy.
Re: What should go into JSX 2.0?
#35Earlier quoted context omitted.
How about { data && } ?
If you render a more complex component this introduces another level of indentation. I can see why some people would prefer cleaner code but in my opinion, indenting ifs is a good thing as it increases the readability and allows you to spot if statements faster.
Re: What should go into JSX 2.0?
#36I like how the if proposal is down voted, probably because it's mentioning Angular. Conditional rendering in React is not always very clean. Most codebases end up resorting with something similar to this in a container to show a spinner while data is loading and rendering it when done. Problem is that the inner component will still be parsed and fail with cannot read property person of undefined. Yes, you can do this…
How about { data && } ?
Re: What should go into JSX 2.0?
#37Earlier quoted context omitted.
I think ternary expression are rather ok here, though not perfect: {cond1 && cond2 ? foo : null }
And you can inline if-statements with an IIFE when you need a little more space: {(() => { if (cond1 && cond2) return foo else ... })()} Though it makes GitHub think it's a Clojure file.
Re: What should go into JSX 2.0?
#38a = {b:'c'}
a?.c //undefined
a.b //'c'
b?.c //undefined
Re: What should go into JSX 2.0?
#39Earlier quoted context omitted.
I think ternary expression are rather ok here, though not perfect: {cond1 && cond2 ? foo : null }
And you can inline if-statements with an IIFE when you need a little more space: {(() => { if (cond1 && cond2) return foo else ... })()} Though it makes GitHub think it's a Clojure file.
Re: What should go into JSX 2.0?
#40I like how the if proposal is down voted, probably because it's mentioning Angular. Conditional rendering in React is not always very clean. Most codebases end up resorting with something similar to this in a container to show a spinner while data is loading and rendering it when done. Problem is that the inner component will still be parsed and fail with cannot read property person of undefined. Yes, you can do this…