Created
September 23, 2018 09:23
-
-
Save rakibulalam/0cd2a2082a7700e246d5912464a33a19 to your computer and use it in GitHub Desktop.
React.js component render for Client Only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ExecutionEnvironment from 'exenv'; | |
/* | |
* Author: Md. Rakibulalam | |
* Dependencies : npm install --save exenv | |
* If you want to exclude render dom releated components from server side render | |
*/ | |
export default (WrappedComponent) => { | |
const hocComponent = ({ ...props }) => { | |
const { canUseDOM } = ExecutionEnvironment; | |
return canUseDOM ? <WrappedComponent {...props} /> : null; | |
}; | |
return hocComponent; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment