DEV Community

Discussion on: Make testable components using the Humble Object pattern

Collapse
 
krofdrakula profile image
Klemen Slavič

I would avoid having the presenter provide DOM event handlers, or state modifiers.

The reason for the first case is that you would essentially make the DOM a dependency of the presenter, and it shouldn't be; it's just a function that transforms props and serves as a facade pattern over the components it's composing.

For the second, even if you provide a new set of photos, the state of those photos is kept outside of this presenter and the presenter is only given the list of photos, therefore it cannot meaningfully affect the photos being passed to the component without risking it going out of sync with the rest of the application.

In this case, you might want to look into Hooks, as the presenter isn't meant to be stateful, just a pure transformation function over the props being passed to it.