0
votes

https://material-ui.com/customization/css-in-js/#withstyles-styles-options-higher-order-component

The last line in the example code

export default withStyles(styles)(MyComponent);

withStyles API says

withStyles(styles, [options]) => higher-order component which does not contain two continuous bracketed components.

What syntax is used in withStyles()()

1

1 Answers

1
votes

It's called Higher-Order Components or Function Composition depending on the context (both are essentially same concept, just viewed differently).

In plain JavaScript, func()() is basically taking the output of one function and passing it to another.

In React and functional programming, this pattern is used to compose different functions into a pipeline of sorts (since React components are essentially just JavaScript functions).