I'm learning react and javascript right now and am struggling to understand why curly braces are required when passing a simple string into a react functional component like so:
function Editor({ headerText }) {
return (
<div className="title">
<span>{headerText}</span>
</div>
);
}
export default Editor;
I understand the concept of object destructuring. However, the headertext parameter is just receiving a basic string. Why do I get syntax errors when trying to remove the curly braces if headerText is just a basic string, so it shouldn't even need the curly braces?
In fact, the react docs have a function similar to this that doesn't even use curly braces:
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
So why is it that my code snippet requires curly braces when the parameter is receiving a simple string value?