Working out how to set states and handle events in the react pattern