Skip to content

Commit

Permalink
refactor: added rootHostName to provider component
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Jan 6, 2022
1 parent 83c1b74 commit a98879a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/portalProvider/PortalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { reducer } from '../../state/reducer';
import type { PortalProviderProps } from './types';

const PortalProviderComponent = ({
rootHostName = 'root',
shouldAddRootHost = true,
children,
}: PortalProviderProps) => {
Expand All @@ -17,7 +18,7 @@ const PortalProviderComponent = ({
<PortalDispatchContext.Provider value={dispatch}>
<PortalStateContext.Provider value={state}>
{children}
{shouldAddRootHost && <PortalHost name="root" />}
{shouldAddRootHost && <PortalHost name={rootHostName} />}
</PortalStateContext.Provider>
</PortalDispatchContext.Provider>
);
Expand Down
9 changes: 9 additions & 0 deletions src/components/portalProvider/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ export interface PortalProviderProps {
* @type boolean
*/
shouldAddRootHost?: boolean;

/**
* Defines the root portal host name.
*
* @default "root"
* @type string
*/
rootHostName?: string;

children: ReactNode | ReactNode[];
}

0 comments on commit a98879a

Please sign in to comment.