apeman-react-mixins
Version:
React mixin set of apeman.
43 lines (33 loc) • 711 B
JSX
/**
* Mixin to handle side (client/server).
* @mixin ApSideMixin
*/
import React, {PropTypes as types} from 'react'
/** @lends ApSideMixin */
let ApSideMixin = {
// --------------------
// Custom
// --------------------
$apSideMixed: true,
/**
* Check if server side or not.
* @returns {boolean}
*/
isSeverSide() {
const s = this
return !s.isClientSide()
},
/**
* Check if client side or not.
* @returns {boolean}
*/
isClientSide () {
const s = this
return (typeof window !== 'undefined') && !!window && !!window.location;
}
// --------------------
// Specs
// --------------------
}
export default Object.freeze(ApSideMixin)