Skip to content

Commit

Permalink
fix(fallback): add fallback props in create Dynamic component (#2031)
Browse files Browse the repository at this point in the history
Co-authored-by: Shubham Sharma - s0s0p6u <[email protected]>
  • Loading branch information
shubham2811 and Shubham Sharma - s0s0p6u authored Jan 10, 2025
1 parent 5b4a692 commit 823ad29
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@xarc/react",
"comment": "use fallback props in create Dynamic component",
"type": "patch"
}
],
"packageName": "@xarc/react"
}
2 changes: 1 addition & 1 deletion packages/xarc-react/src/common/create-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class SubAppComponent extends Component {
this._options = props.__options;
this.resolveName = this._options.resolveName || this.subapp.resolveName;
this.state = this.makeState();
this.loading = <div>subapp {this.subapp.name} component loading... </div>;
this.loading = this._options.fallback || <div>subapp {this.subapp.name} component loading... </div>;
this._info = { component: this, subapp: props.__subapp, type: "dynamic" };
this.subapp._mount(this._info);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/subapp2-poc/src/static.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { xarcV2 } from "@xarc/react";
import { demo1 } from "./home";
import custom from "./styles/custom.module.css"; // eslint-disable-line no-unused-vars

const Demo1 = createDynamicComponent(demo1, { ssr: true });
const Demo1 = createDynamicComponent(demo1, { ssr: true, fallback: <div>Loading...</div>});

xarcV2.debug("static.tsx");
const StaticHome = props => {
Expand Down

0 comments on commit 823ad29

Please sign in to comment.