Skip to content

Instantly share code, notes, and snippets.

@rakibulalam
Created September 23, 2018 09:23
Show Gist options
  • Save rakibulalam/0cd2a2082a7700e246d5912464a33a19 to your computer and use it in GitHub Desktop.
Save rakibulalam/0cd2a2082a7700e246d5912464a33a19 to your computer and use it in GitHub Desktop.
React.js component render for Client Only
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