Skip to content

Commit

Permalink
return null
Browse files Browse the repository at this point in the history
  • Loading branch information
maapteh committed Nov 23, 2019
1 parent 2bb2202 commit d770b3d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var DefaultOnSSR = function () { return React.createElement("span", null); };
var NoSSR = function (_a) {
var children = _a.children, _b = _a.onSSR, onSSR = _b === void 0 ? React.createElement(DefaultOnSSR, null) : _b;
var children = _a.children, _b = _a.onSSR, onSSR = _b === void 0 ? null : _b;
var _c = React.useState(false), render = _c[0], setRender = _c[1];
React.useEffect(function () { return setRender(true); }, []);
if (!render) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpth/react-no-ssr",
"version": "0.0.5",
"version": "0.0.7",
"description": "React component to wrap non SSR components.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 1 addition & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from 'react';

const DefaultOnSSR = () => <span />;

interface Props {
children: any; // React.ReactNode
onSSR?: any; // JSX.Element
}

const NoSSR = ({ children, onSSR = <DefaultOnSSR /> }: Props) => {
const NoSSR = ({ children, onSSR = null }: Props) => {
const [render, setRender] = React.useState(false);

React.useEffect(() => setRender(true), []);
Expand Down

0 comments on commit d770b3d

Please sign in to comment.