Properties of undefined object returns error

Properties of state should not be called if state is undefined. Causes JS error which breaks all JS on a page.