Fix memory leak with renderComponentToString()

This is leaking memory. Move event registration to mount time.