DEV Community

Discussion on: Writing fully testable React components using the 'Helper Pattern'

Collapse
 
ashubuntu profile image
ashubuntu

Rather than using one helper per component, it would be nice to have a common helper/base class to handle CRUD for all components. In that case, each component may have to take the responsibility of mere initializing its state and delegate all other functionalities as you have shown here.

Collapse
 
siddiqus profile image
Sabbir Siddiqui

Absolutely! The main idea of the article was to pass the component's object using "this" through to the constructor of the helper and having it manage the component's state. What you mentioned makes sense, and it's something I have also applied in practice. Also definitely helps when you have similar components across your application. Thanks for your feedback!