@lolyjs/core 0.2.0-alpha.4 → 0.2.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5720,6 +5720,28 @@ function AppShell({
5720
5720
  window.removeEventListener("popstate", handlePopState, false);
5721
5721
  };
5722
5722
  }, []);
5723
+ useEffect(() => {
5724
+ const handleDataRefresh = () => {
5725
+ const freshData = window?.__FW_DATA__;
5726
+ if (!freshData) return;
5727
+ const currentPathname = window.location.pathname;
5728
+ const freshPathname = freshData.pathname;
5729
+ if (freshPathname === currentPathname) {
5730
+ if (freshData.metadata !== void 0) {
5731
+ applyMetadata(freshData.metadata);
5732
+ }
5733
+ setState((prevState) => ({
5734
+ ...prevState,
5735
+ props: freshData.props ?? prevState.props,
5736
+ params: freshData.params ?? prevState.params
5737
+ }));
5738
+ }
5739
+ };
5740
+ window.addEventListener("fw-data-refresh", handleDataRefresh);
5741
+ return () => {
5742
+ window.removeEventListener("fw-data-refresh", handleDataRefresh);
5743
+ };
5744
+ }, [state.url]);
5723
5745
  const isError = state.route === errorRoute;
5724
5746
  const isNotFound = state.route === notFoundRoute;
5725
5747
  const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";