Update component.js

Improve code.