diff --git a/packages/prism-react-renderer/src/components/highlight.ts b/packages/prism-react-renderer/src/components/highlight.ts index 3c6d5d5..3d23ddc 100644 --- a/packages/prism-react-renderer/src/components/highlight.ts +++ b/packages/prism-react-renderer/src/components/highlight.ts @@ -1,8 +1,8 @@ import { InternalHighlightProps } from "../types" -import { useThemeDictionary } from "./useThemeDictionary" import { useGetLineProps } from "./useGetLineProps" import { useGetTokenProps } from "./useGetTokenProps" import { useTokenize } from "./useTokenize" +import themeToDict from "../utils/themeToDict" export const Highlight = ({ children, @@ -12,7 +12,7 @@ export const Highlight = ({ prism, }: InternalHighlightProps) => { const language = _language.toLowerCase() - const themeDictionary = useThemeDictionary(language, theme) + const themeDictionary = themeToDict(theme, language) const getLineProps = useGetLineProps(themeDictionary) const getTokenProps = useGetTokenProps(themeDictionary) const grammar = prism.languages[language] diff --git a/packages/prism-react-renderer/src/components/useThemeDictionary.ts b/packages/prism-react-renderer/src/components/useThemeDictionary.ts deleted file mode 100644 index fd6746f..0000000 --- a/packages/prism-react-renderer/src/components/useThemeDictionary.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Language, PrismTheme } from "../types" -import { useEffect, useRef, useState } from "react" -import themeToDict, { ThemeDict } from "../utils/themeToDict" - -export const useThemeDictionary = (language: Language, theme: PrismTheme) => { - const [themeDictionary, setThemeDictionary] = useState( - themeToDict(theme, language) - ) - const previousTheme = useRef() - const previousLanguage = useRef() - - useEffect(() => { - if ( - theme !== previousTheme.current || - language !== previousLanguage.current - ) { - previousTheme.current = theme - previousLanguage.current = language - setThemeDictionary(themeToDict(theme, language)) - } - }, [language, theme]) - - return themeDictionary -}