From the course: React: Design Patterns
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Partially applied components - React.js Tutorial
From the course: React: Design Patterns
Partially applied components
- [Instructor] All right, so the last functional programming concept that we're going to take a look at here in the context of React is something called partial application. Now, partial application, just to give you a simple example of this in JavaScript, is when we take a certain number of arguments in a function and fix them to specific values. So what we're left with is a more specific version of a more general function. Let me show you what that looks like. If we have a function here, and we'll call it something like getPropertyWithDefault, right? Let's say that this is supposed to get a value for a key from an object. What that might look like is this. We might take, let's say, the key that we want to look for, as well as the default value, and finally, the object that we want to get that from. Now, the implementation of this function's pretty straightforward, but it could definitely be a useful function here that saves us from having to do this same thing over and over again…