Skip to content

Commit

Permalink
refactor: removed index files
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Jan 6, 2022
1 parent 9d0a5db commit 83c1b74
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 31 deletions.
6 changes: 2 additions & 4 deletions src/components/portal/Portal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import { nanoid } from 'nanoid/non-secure';
import { usePortal } from '../../hooks';
import { usePortal } from '../../hooks/usePortal';
import type { PortalProps } from './types';

const PortalComponent = ({
Expand Down Expand Up @@ -77,7 +77,5 @@ const PortalComponent = ({
return null;
};

const Portal = memo(PortalComponent);
export const Portal = memo(PortalComponent);
Portal.displayName = 'Portal';

export default Portal;
1 change: 0 additions & 1 deletion src/components/portal/index.ts

This file was deleted.

7 changes: 3 additions & 4 deletions src/components/portalHost/PortalHost.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { memo, useEffect } from 'react';
import { usePortal, usePortalState } from '../../hooks';
import { usePortalState } from '../../hooks/usePortalState';
import { usePortal } from '../../hooks/usePortal';
import type { PortalHostProps } from './types';

const PortalHostComponent = ({ name }: PortalHostProps) => {
Expand All @@ -23,7 +24,5 @@ const PortalHostComponent = ({ name }: PortalHostProps) => {
//#endregion
};

const PortalHost = memo(PortalHostComponent);
export const PortalHost = memo(PortalHostComponent);
PortalHost.displayName = 'PortalHost';

export default PortalHost;
1 change: 0 additions & 1 deletion src/components/portalHost/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/portalHost/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface PortalHostProps {
/**
* Host's key or name to be used as an identifer.
* Host's key or name to be used as an identifier.
* @type string
*/
name: string;
Expand Down
14 changes: 8 additions & 6 deletions src/components/portalProvider/PortalProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { memo, useReducer } from 'react';
import PortalHost from '../portalHost';
import { PortalDispatchContext, PortalStateContext } from '../../contexts';
import { reducer, INITIAL_STATE } from '../../state';
import { PortalHost } from '../portalHost/PortalHost';
import {
PortalDispatchContext,
PortalStateContext,
} from '../../contexts/portal';
import { INITIAL_STATE } from '../../state/constants';
import { reducer } from '../../state/reducer';
import type { PortalProviderProps } from './types';

const PortalProviderComponent = ({
Expand All @@ -19,7 +23,5 @@ const PortalProviderComponent = ({
);
};

const PortalProvider = memo(PortalProviderComponent);
export const PortalProvider = memo(PortalProviderComponent);
PortalProvider.displayName = 'PortalProvider';

export default PortalProvider;
1 change: 0 additions & 1 deletion src/components/portalProvider/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/contexts/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/contexts/portal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from 'react';
import type { ActionTypes } from '../state';
import type { ActionTypes } from '../state/types';
import type { PortalType } from '../types';

export const PortalStateContext = createContext<Record<
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/usePortal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode, useCallback, useContext } from 'react';
import { ACTIONS } from '../state/constants';
import { PortalDispatchContext } from '../contexts';
import { PortalDispatchContext } from '../contexts/portal';

export const usePortal = (hostName: string = 'root') => {
const dispatch = useContext(PortalDispatchContext);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePortalState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { PortalStateContext } from '../contexts';
import { PortalStateContext } from '../contexts/portal';

export const usePortalState = (hostName: string) => {
const state = useContext(PortalStateContext);
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as Portal } from './components/portal';
export { default as PortalHost } from './components/portalHost';
export { default as PortalProvider } from './components/portalProvider';
export { Portal } from './components/portal/Portal';
export { PortalHost } from './components/portalHost/PortalHost';
export { PortalProvider } from './components/portalProvider/PortalProvider';
export { usePortal } from './hooks/usePortal';
export { enableLogging } from './utilities/logger';
3 changes: 0 additions & 3 deletions src/state/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utilities/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if (__DEV__) {
} else {
message = `${params ?? ''}`;
}
// eslint-disable-next-line no-console
console.log(
`[Portal::${[component, method].filter(Boolean).join('::')}]`,
message
Expand Down

0 comments on commit 83c1b74

Please sign in to comment.