Reusing functions is one of our goals as developers, and we have seen how React makes it easy to create reusable components. Reusable components can be shared across multiple domains of your application to avoid duplication.
Small components with a clean interface can be composed together to create complex applications that are powerful and maintainable at the same time.
Composing React components is pretty straightforward; you just have to include them in the render method:
import { object } from 'prop-types';
const Profile = ({ user }) => (
<div>
<Picture profileImageUrl={user.profileImageUrl} />
<UserName name={user.name} screenName={user.screenName} />
</div>
);
Profile.propTypes = {
user: object
};
For example, you can create a Profile component by simply composing a...