0

Check this function below, what would I call the thread thats coming in on this function below, is it a parameter? or is it a destructured part of an object? does the curly brace mean this is still a parameter? im just a little confused

const ChatThread = ({thread}) => {

return (
<div>
</div>
)
}

if I do the same function like below i get an error with the thread, why is it required to use the curly braces to get the data?

const ChatThread = (thread) => {

return (
<div>
</div>
)
}
AmandaConda
  • 223
  • 3
  • 13
  • What exactly is the error? In the code you posted, there should be no difference because the function does not use the parameter anyway. – Pointy Sep 02 '21 at 21:37
  • I just want to know syntax, is it still technically called a parameter if it has curly braces? – AmandaConda Sep 02 '21 at 21:39
  • 1
    That does answer my question! – AmandaConda Sep 02 '21 at 21:42
  • 3
    (thread) => is a parameter(object) passed to this function. ({thread}) this is like extracting the property thread from passed parameter. In short this is like param.thread. so it's destructuring – navnath Sep 02 '21 at 22:13
  • 2
    Short answer: `({thread})` expects an object (note the curly braces) containing the property `thread`, whereas `(thread)` expects any parameter – testing_22 Sep 02 '21 at 22:39

0 Answers0