I want to understand the double return function in Javascript
I went through the other questions which was asked in SF regarding the return statement but I wasn't able to make sense out of it.
So, I was trying to understand HOC in react when I stumbled upon an article on medium.
The author wrote this line of code in his example.
const yell = (PassedComponent) =>
({ children, ...props }) =>
<PassedComponent {...props}>
{children.toUpperCase()}!
</PassedComponent>
const Title = (props) => <h1>{props.children}</h1>
const AngryTitle = yell(Title)
<AngryTitle>Whatever</AngryTitle>
//=> <h1>WHATEVER!</h1>
Our HOC (Yell) here can also be return as
const yell = PassedComponent => ({children, ...props}) => {
return (
Since there is two arrow function and something like this after first arrow function ({children, ...props})
, I think it is double return HOC function.
[Question]: Can someone explain me double return or the code above?.