Now we're going to create a new component here, it's going to be called app, and what we're going to end up rendering is our mixed in button. Down here in our component, which I'm going to go ahead and rename to button, so we've got our button, we've got our onClick which is now going to be, is fine, but our count is going to be. increment, and I'm also going to just pass in as a prop, this.state. Now, I'm going to pass in update as a prop, that's going to be equal to the. Going to create a new render method in our mixin, and this is going to return our inner component, the component that was passed into our mixin function. I'm going to grab all this good stuff here, and I'm going to paste it in there, also grab this componented mount and drop it right here. So, it's going to return a new component, we're going to take in a component, we're going to return a new component. We've got this very simple component here, and to create our first mix-in what we're going to do is say, "let react mixin", space there, equal, now this is going to be a function, it's going to take an inner component and it's going to return, class extend ponent. So we're going to take a look at this right now. Some people are going to call it higher-order functions, perhaps a higher-order component, but it's just a function. So one thing an ES6 components do not support is mixins, and there are a lot of variations on how to achieve the same results as the mixins.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |