import React , { Component } from 'react' ; interface State { isCsr : boolean ; } function onlyCsr ( WrappedComponent ) { class OnlyCsrClass extends Component < any , State > { constructor ( props ) { super ( props ) ; this . state = { isCsr : false } ; } componentDidMount ( ) { this . setState ( { isCsr : true } ) ; } render ( ) { return this . state . isCsr ? < WrappedComponent { ... this . props } > < /WrappedComponent> : <div></div > ; } } for ( const key in WrappedComponent ) { OnlyCsrClass [ key ] = WrappedComponent [ key ] ; } return OnlyCsrClass ; } export default onlyCsr ;