How to understand such a function as a = > b = > c

how to understand the code well in the case of cascading high-order functions with multiple arrow functions in es6

const setTitle = (title) => (WrappedComponent) => {
   return class extends React.Component {
      componentDidMount() {
          document.title = title
      }
      render() {
         return <WrappedComponent {...this.props} />
      }
   }
}

PS asked: I can understand what everyone said, but I have to change it in my head every time. I feel that the readability of the code is not particularly good, or maybe I am too lame. And is it possible to write two layers at most in this way?


is actually the Coreification of ES6, that is, first define a function, and then return a new function to accept the second parameter
:
can be more than two layers.


const setTitle = (title) => (WrappedComponent) => {}
//
const setTitle = function(title){
    return function(WrappedComponent){
       
    }
}

const setTitle = (title) => {
return (WrappedComponent) => {
   return class extends React.Component {
      componentDidMount() {
          document.title = title
      }
      render() {
         return <WrappedComponent {...this.props} />
      }
   }
 }
}

from right to left, which is equivalent to (title) = > {return () = > {}}


http://blog.oneapm.com/apm-te.


const a => b => c => { /* code */ }
// 
const c = (a, b) => { /* code */ }

the first way of writing can be regarded as the second kind of Creed

Menu