Skip to content

Commit

Permalink
re-name utility to avoid rule of hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Jan 13, 2022
1 parent 2fcbe58 commit 0de64b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.26",
"version": "0.2.27",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { classNames } from '../utils';
import { Text } from '../content';
import { Icon, CloseOutline } from '../icon';
import { useSeverityStyle } from './useSeverityStyle';
import { useSeverityIcon } from './useSeverityIcon';
import { getSeverityIcon } from './getSeverityIcon';
import { SeverityLevel } from '../types';
export interface AlertProps {
variant: SeverityLevel;
Expand Down Expand Up @@ -57,7 +57,7 @@ export const Alert = ({
let variantStyle = useSeverityStyle(variant);

if (!icon && showIcon) {
icon = useSeverityIcon(variant);
icon = getSeverityIcon(variant);
}
return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type IconOptions = {
*/
filled?: boolean;
};
export function useSeverityIcon(
export function getSeverityIcon(
severity: SeverityLevel,
{ filled }: IconOptions = { filled: true }
) {
Expand Down
5 changes: 3 additions & 2 deletions src/notification/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { css } from '@emotion/core';
import { NoticeConfig } from './types';
import { Text } from '../content';
import { useSeverityStyle } from '../alert/useSeverityStyle';
import { useSeverityIcon } from '../alert/useSeverityIcon';
import { getSeverityIcon } from '../alert/getSeverityIcon';
import { Icon, CloseOutline } from '../icon';
import theme from '../theme';
import { DEFAULT_EXPIRE_MS } from './constants';
Expand Down Expand Up @@ -38,6 +38,7 @@ export function Notice({
return () => clearTimeout(timer);
}
return () => {}; // Void function
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Get the styles for the specific variant
Expand All @@ -64,7 +65,7 @@ export function Notice({
}
`}
>
{useSeverityIcon(variant)}
{getSeverityIcon(variant)}

<Text elementType="h5" textSize="large" weight="heavy" color="inherit">
{title}
Expand Down

0 comments on commit 0de64b6

Please sign in to comment.