Where did Vue.js come from?
at modernweb.com▼4 up and 1 down, posted by
4 up and 1 down, posted by
React did not invent Higher Order Components, it's not even part of React API. You can do higher order components with any component-based framework, including Vue: https://medium.com/tldr-tech/higher-order-components-in-vue-js-38b500c6d49f IMO, React biggest advantage compared to Vue is money and marketing.
Those concepts exist in pretty much any programming language. @sylvainpv I'm searching the web for Vue.JS examples where a component gets passed in as prop to another component. Not finding anything so far. Do you know if that is even possible? Doesn't this conflict with the reactive data-structure stuff going on in Vue.JS? To give you a more concrete example: In the last project we needed inline-editing functionality. The goal was to support different input elements like text, select, etc. and the view could also be different from case to case. This was pretty nice and elegant to solve using a higher order component, which basicly looked like this in React: <InlineEdit editComponent={SomeInputComponent} viewComponent={SomeViewComponent} value={val} onChange={(newVal) => { /* do something */}} /> How would you approach that in Vue.JS?Nice! Thanks for the code snippet :-) You are right, that's not any less elegant than in React. Is there also a nice solution for these kind of constructs in Vue.JS? function createComponentWithDefaultProps(Component, defaultProps) { return function(props) { return <Component {...defaultProps} {...props} /> } }