Implicit returns: example of how you’d use () => ({ }) syntax with a multi-line function? How does it know which expression to return?
Answer: https://medium.com/@bunlong/arrow-functions-return-rules-in-javascript-b63ed5f25994 Check this out Barish! It looks like “multiline” just represents one statement spread out on multiple lines for implicit return. I believe you only can still have one item/variable/param/arg returned via the multiline implicit.
Is there a way to define properties with JSX expressions that include evaluated expressions inside strings like we usually do using template literals? (e.g. className=${value} otherClass
). The only method I found searching around was to define the string elsewhere and then plug it in as a single evaluated expression.
Answer: You should be able to still use template literal expressions like this:
<a className={ `someString${this.props.data.imageUrl}` }>
Answer: The reality for most big applications is there is just going to be a ton of components. There's no specific plan around minimizing components because at the end of the day if you have 100 different parts of your web application then you will need 100 (or more) different components.
The lecture material and documentation seemed pretty explicit that the setState syntax is: setState((props, etc) => {state: ...}), but the labs made use of it with just: setState({state:...}). When would you use one or the other?
Answer: Yes! The labs are actually incorrect in this case. When referencing this.state in setState, always use the setState method shown in lecture, otherwise you are okay to not use it.