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
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/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",
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;