Components do not have to return JSX. Numbers, strings, and even null are valid return values.

If a function returns, code following that return statement is never executed. In the snippet you pasted, if global.x is truthy, then the function returns, and the proceeding code is ignored. That means the global.y is never accessed, because the function returned before global.y would have been accessed. Since global.y is never accessed, the component never subscribes to global.y. If global.x is falsey, then the component does not return early, and global.y is accessed, making the component subscribe to changes in global.y.

Senior front end engineer / charlesstover.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store