survivejs / react-book

From apprentice to master (CC BY-NC-ND)
https://survivejs.com/react/introduction/
2.02k stars 366 forks source link

[I 6.6 - Implementing Edit] - parameter order & {true} #440

Closed JESii closed 7 years ago

JESii commented 7 years ago

1) In this section, you change const Edit = ({onEdit = () => {}, value, ...props}) => ( to const {value, onEdit, ...props} = Why the change in the order of parameters? And wouldn't that matter?

2) Later, in the return statement you have: autoFocus={true} Why is true enclosed in {}? Since it's a constant, shouldn't that just be: autoFocus=true? I mean, it'll work ok because it is a constant...

bebraw commented 7 years ago
  1. The order doesn't matter.
  2. I would write just autoFocus now as that's equivalent. I think I used braces so it's consistent.
JESii commented 7 years ago

Got it; thanks! ... Oh; of course -- because it's just an object.

JESii commented 7 years ago

Actually, the braces ARE required -- without them you get this error from the build step: Module build failed: SyntaxError: JSX value should be either an expression or a quoted JSX text (22:13)

bebraw commented 7 years ago

@JESii Yeah. But note that autoFocus={true} and autoFocus are equivalent based on the current JSX specification.