Added constructComponent() method and tests.

Added constructComponent() method to construct a component from its
data instead of requiring a component to be passed in by the user.