user2066880
user2066880

Reputation: 5024

Combining react components

Say I have 2 components. Component A renders an input that scales dynamically to its text. Component B renders an input with autocomplete capabilities. Is there a standard way to combine the 2 so that I can have a component that renders an input with autocomplete capabilities and that scales dynamically? One pattern is to wrap one component with the other, so that A renders B. But in the case that the components are a black box, like imported from a node module, this wouldn't be possible right?

Upvotes: 1

Views: 850

Answers (1)

GMchris
GMchris

Reputation: 5658

You should look into Mixins. Create a single Input component, and create an "Autocomplete" and "scale" mixins. More on the subject here.

Upvotes: 1

Related Questions