fix: pr review - remove unneeded useState and useEffect in SessionEmojiPanel

pull/2522/head
William Grant 3 years ago
parent be21f29875
commit 172510d11b

@ -1,4 +1,4 @@
import React, { forwardRef, useEffect, useState } from 'react'; import React, { forwardRef } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import styled from 'styled-components'; import styled from 'styled-components';
// @ts-ignore // @ts-ignore
@ -103,31 +103,29 @@ export const SessionEmojiPanel = forwardRef<HTMLDivElement, Props>((props: Props
const theme = useSelector(getTheme); const theme = useSelector(getTheme);
const isDarkMode = useSelector(isDarkTheme); const isDarkMode = useSelector(isDarkTheme);
const [panelBackgroundRGB, setPanelBackgroundRGB] = useState(''); let panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1);
const [panelTextRGB, setPanelTextRGB] = useState(''); let panelTextRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6);
useEffect(() => { switch (theme) {
switch (theme) { case 'ocean-dark':
case 'ocean-dark': panelBackgroundRGB = hexColorToRGB(THEMES.OCEAN_DARK.COLOR1);
setPanelBackgroundRGB(hexColorToRGB(THEMES.OCEAN_DARK.COLOR1)); // tslint:disable: no-non-null-assertion
// tslint:disable: no-non-null-assertion panelTextRGB = hexColorToRGB(THEMES.OCEAN_DARK.COLOR7!);
setPanelTextRGB(hexColorToRGB(THEMES.OCEAN_DARK.COLOR7!)); break;
break; case 'ocean-light':
case 'ocean-light': // tslint:disable: no-non-null-assertion
// tslint:disable: no-non-null-assertion panelBackgroundRGB = hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR7!);
setPanelBackgroundRGB(hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR7!)); panelTextRGB = hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR1);
setPanelTextRGB(hexColorToRGB(THEMES.OCEAN_LIGHT.COLOR1)); break;
break; case 'classic-light':
case 'classic-light': panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR6);
setPanelBackgroundRGB(hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR6)); panelTextRGB = hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR0);
setPanelTextRGB(hexColorToRGB(THEMES.CLASSIC_LIGHT.COLOR0)); break;
break; case 'classic-dark':
case 'classic-dark': default:
default: panelBackgroundRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1);
setPanelBackgroundRGB(hexColorToRGB(THEMES.CLASSIC_DARK.COLOR1)); panelTextRGB = hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6);
setPanelTextRGB(hexColorToRGB(THEMES.CLASSIC_DARK.COLOR6)); }
}
}, [theme]);
return ( return (
<StyledEmojiPanel <StyledEmojiPanel

Loading…
Cancel
Save