Add state example

Also made change to call render automatically when state is changed.