Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions apps/router-demo/router-host-2000/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
useEffect,
ForwardRefExoticComponent,
Suspense,
useState,
} from 'react';
import { Route, Routes, useLocation } from 'react-router-dom';
import {
Expand Down Expand Up @@ -284,16 +285,26 @@ const App = () => {
/>
<Route
path="/remote6/*"
Component={() => (
<Remote6App
rootOptions={{
identifierPrefix: 'remote6-instance-',
onRecoverableError: (error: Error) => {
console.error('[Host] Remote6 recoverable error:', error);
},
}}
/>
)}
Component={() => {
const [counter, setCounter] = useState(0);

return (
<>
<button onClick={() => setCounter(counter + 1)}>
Increment
</button>
<Remote6App
outerCounter={counter}
rootOptions={{
identifierPrefix: 'remote6-instance-',
onRecoverableError: (error: Error) => {
console.error('[Host] Remote6 recoverable error:', error);
},
}}
/>
</>
);
}}
/>
</Routes>
</div>
Expand Down
23 changes: 17 additions & 6 deletions apps/router-demo/router-remote6-2006/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'react-router';
import './App.css';
import styled from '@emotion/styled';
import { useState } from 'react';

const HomeDiv = styled.div`
color: purple;
Expand Down Expand Up @@ -48,16 +49,21 @@ function Home() {
}

function Detail() {
const [counter, setCounter] = useState(0);
return (
<>
<h2>Remote6 detail page</h2>
<div>hello remote6 detail page with React Router v7</div>
<div>🚀 Enhanced routing with better performance and DX</div>
<Image
width={200}
src="https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp"
alt="Sample image"
/>
<div style={{ fontSize: 40 }}>Inner Counter: {counter}</div>
<button onClick={() => setCounter(counter + 1)}>Increment</button>
<div>
<Image
width={200}
src="https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp"
alt="Sample image"
/>
</div>
</>
);
}
Expand Down Expand Up @@ -171,7 +177,11 @@ const router = createBrowserRouter([
},
]);

const App = (info?: { basename?: string; initialEntries?: Array<string> }) => {
const App = (info?: {
outerCounter: number;
basename?: string;
initialEntries?: Array<string>;
}) => {
// React Router v7 supports more advanced routing features
// For now, we'll use the basic router configuration
// In a real app, you might want to handle basename and initialEntries
Expand All @@ -180,6 +190,7 @@ const App = (info?: { basename?: string; initialEntries?: Array<string> }) => {

return (
<div className="remote6-app">
<div style={{ fontSize: 40 }}>Outer Counter: {info?.outerCounter}</div>
<RouterProvider router={router} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function createBaseBridgeComponent<T>({
const beforeBridgeRenderRes =
instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info) || {};

const BridgeWrapper = ({ basename }: { basename?: string }) => (
const rootComponentWithErrorBoundary = (
<ErrorBoundary
FallbackComponent={fallback as React.ComponentType<FallbackProps>}
>
Expand All @@ -85,10 +85,6 @@ export function createBaseBridgeComponent<T>({
</ErrorBoundary>
);

const rootComponentWithErrorBoundary = (
<BridgeWrapper basename={basename} />
);

if (bridgeInfo.render) {
await Promise.resolve(
bridgeInfo.render(rootComponentWithErrorBoundary, dom),
Expand Down