Make inject() a bit more robust, by quickly bailing when there is no window defined.
Better idea: use ExecutionContext.canUseDOM from React.