Component events

UI applications have user events; in the web, they came in the form of DOM events. As React wraps each DOM element into React elements, handling them will be a little different yet very familiar.

For this next example, let's suppose that our application will allow users to delete an investment. We could write this requirement through the following acceptance criterion:

Given an investment, InvestmentListItem should notify an observer onClickDelete when the delete button is clicked on.

The idea here is the same as presented in the Integrate Views with observers section of Chapter 3, Testing Frontend Code.

So, how should we set the observer in a component? As we've already seen previously, props are the way to pass attributes to our ...

Get Jasmine JavaScript Testing - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.