Decouple shlink-web-component from NotFound component

This commit is contained in:
Alejandro Celaya
2023-07-31 20:52:08 +02:00
parent c73a592fd1
commit 5ec5396da6
4 changed files with 19 additions and 13 deletions

View File

@@ -11,10 +11,11 @@ import type { Settings } from './utils/settings';
import { SettingsProvider } from './utils/settings';
type ShlinkWebComponentProps = {
routesPrefix?: string;
settings?: Settings;
serverVersion: SemVer;
apiClient: ShlinkApiClient;
routesPrefix?: string;
settings?: Settings;
createNotFound?: (nonPrefixedHomePath: string) => ReactNode;
};
// FIXME
@@ -24,7 +25,7 @@ let apiClientRef: ShlinkApiClient;
export const createShlinkWebComponent = (
bottle: Bottle,
): FC<ShlinkWebComponentProps> => ({ serverVersion, apiClient, settings, routesPrefix = '' }) => {
): FC<ShlinkWebComponentProps> => ({ serverVersion, apiClient, settings, routesPrefix = '', createNotFound }) => {
const features = useFeatures(serverVersion);
const mainContent = useRef<ReactNode>();
const [theStore, setStore] = useState<Store | undefined>();
@@ -37,7 +38,7 @@ export const createShlinkWebComponent = (
// depend on it
const { container } = bottle;
const { Main, store, loadMercureInfo } = container;
mainContent.current = <Main />;
mainContent.current = <Main createNotFound={createNotFound} />;
setStore(store);
// Load mercure info