Listen to events on demand

Fixes #381

This is a squashed version of https://github.com/facebook/react/pull/462