Skip to content

Commit

Permalink
feat: used react fragment for better classname handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tea-lover-418 committed Jun 4, 2022
1 parent a55e920 commit e4f6429
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-loading-iframe",
"version": "1.0.4",
"version": "1.1.0",
"description": "",
"source": "src/index.tsx",
"main": "dist/main.js",
Expand Down
7 changes: 5 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react";
import {
Fragment,
FunctionComponent,
IframeHTMLAttributes,
ReactElement,
Expand All @@ -11,6 +12,7 @@ interface Props extends IframeHTMLAttributes<any> {
skeleton?: ReactElement;
}

/** An iframe that takes a skeleton as a prop and renders the skeleton until the iframe is ready */
const LoadingIframe: FunctionComponent<Props> = (props) => {
const { skeleton, className, ...iframeProps } = props;
const [iframeLoading, setIframeLoading] = useState(true);
Expand All @@ -22,9 +24,10 @@ const LoadingIframe: FunctionComponent<Props> = (props) => {
}

return (
<div className={className}>
<Fragment>
{iframeLoading && skeleton}
<iframe
className={className}
{...iframeProps}
style={{
display: iframeLoading ? "none" : "block",
Expand All @@ -35,7 +38,7 @@ const LoadingIframe: FunctionComponent<Props> = (props) => {
setIframeLoading(false);
}}
/>
</div>
</Fragment>
);
};

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"removeComments": true
"allowSyntheticDefaultImports": true
},
"include": ["/src/*/*.tsx", "/src/*/*.ts"],
"exclude": [
Expand Down

0 comments on commit e4f6429

Please sign in to comment.