Skip to content

Commit

Permalink
chore: add counter to show fast-refresh is working (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
hardfist authored Jan 22, 2024
1 parent 57ca4bf commit af0e9e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages:
- "rspack/*"
- "rspack/**"
- "rsbuild/*"
- "rspress/*"
- "modernjs/*"
28 changes: 19 additions & 9 deletions rspack/module-federation-v1.5/lib1/src/Component.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import { formatRelative, subDays } from "date-fns";
import { useEffect, useState } from "react";
// date-fns is a shared module, but used as usual
// exposing modules act as async boundary,
// so no additional async boundary need to be added here
// As data-fns is an shared module, it will be placed in a separate file
// It will be loaded in parallel to the code of this module

const Component = ({ locale }) => (
<div style={{ border: "5px solid darkblue" }}>
<p>I'm a Component exposed from container B!</p>
<p>
Using date-fn in Remote:{" "}
{formatRelative(subDays(new Date(), 2), new Date(), { locale })}
</p>
</div>
);
const Component = ({ locale }) => {
let [cnt, setCnt] = useState(0);
useEffect(() => {
setInterval(() => {
setCnt(x => x+1);
}, 1000)
},[])
return (
<div style={{ border: "5px solid darkblue" }}>
<div>cnt: {cnt}</div>
<p>I'm a Component exposed from container B!</p>
<p>
Using date-fn in Remote:{" "}
{formatRelative(subDays(new Date(), 2), new Date(), { locale })}
</p>
</div>
);
};
export default Component;

0 comments on commit af0e9e8

Please sign in to comment.