From 0293d6821e8a66225338c4f41af5cf08837bb4d0 Mon Sep 17 00:00:00 2001 From: maapteh Date: Sun, 24 Nov 2019 18:06:06 +0100 Subject: [PATCH 1/3] change prop for fallback into fallback just like suspense --- README.md | 2 +- dist/index.js | 13 ------------- src/index.spec.tsx | 2 +- src/index.tsx | 6 +++--- 4 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 dist/index.js diff --git a/README.md b/README.md index 54bad530..08e7f64a 100755 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ const Loading = () => (
Loading...
); const Page = () => ( <> .... - }> + }> diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 43205e25..00000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var React = require("react"); -var NoSSR = function (_a) { - 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) { - return onSSR; - } - return children; -}; -exports.default = NoSSR; diff --git a/src/index.spec.tsx b/src/index.spec.tsx index 906c1b72..c6e37210 100644 --- a/src/index.spec.tsx +++ b/src/index.spec.tsx @@ -28,7 +28,7 @@ describe('NoSSR Component', () => { const Loading = () =>
Loading...
; it('should render correctly with custom loading', () => { - const markup = ReactDOMServer.renderToStaticMarkup(}> + const markup = ReactDOMServer.renderToStaticMarkup(}> ); expect(markup).toBe('
Loading...
') diff --git a/src/index.tsx b/src/index.tsx index 2ec40812..f7e6bebc 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,16 +2,16 @@ import * as React from 'react'; interface Props { children: any; // React.ReactNode - onSSR?: any; // JSX.Element + fallback?: any; // JSX.Element } -const NoSSR = ({ children, onSSR = null }: Props) => { +const NoSSR = ({ children, fallback = null }: Props) => { const [render, setRender] = React.useState(false); React.useEffect(() => setRender(true), []); if (!render) { - return onSSR; + return fallback; } return children; From e653aece06b8bb9aff706e66ad7237ce5f7bb274 Mon Sep 17 00:00:00 2001 From: maapteh Date: Sun, 24 Nov 2019 18:06:30 +0100 Subject: [PATCH 2/3] no dist in src anymore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7ef1fd6e..d0dbd23c 100755 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ yarn-error.log node_modules coverage +dist \ No newline at end of file From 4fe1b15eaa2f2de74c81bc1e7ba006df0cac6efc Mon Sep 17 00:00:00 2001 From: maapteh Date: Sun, 24 Nov 2019 18:08:05 +0100 Subject: [PATCH 3/3] 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 87aa2351..af67e96c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mpth/react-no-ssr", - "version": "0.0.8", + "version": "1.0.0", "description": "React component to wrap non SSR components.", "main": "dist/index.js", "types": "dist/index.d.ts",