Topic: ReactJs tech question
tqminh free asked 4 years ago
Expected behavior I see the following definition in the code like this:
toggleTab = tab => () => { const { activeItem } = this.state; if (activeItem !== tab) { this.setState({ activeItem: tab }); } };
It is something like arrow function but a bit different. Can I know the name of the technique you used above?
Piotr Glejzer staff answered 4 years ago
This is calling a curried function.
Here is a topic about that on StackOverflow :
https://stackoverflow.com/questions/32782922/what-do-multiple-arrow-functions-mean-in-javascript/32784025
and some article about it:
https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB React
- MDB Version: 4.25.2
- Device: Any
- Browser: Any
- OS: Any
- Provided sample code: No
- Provided link: No