From 58bbe988f32a6a33e91b9e50c1a86687e9a35826 Mon Sep 17 00:00:00 2001 From: "raohai.rh" Date: Fri, 4 Sep 2020 08:39:38 +0800 Subject: [PATCH] feat: version to 2.0.1 --- package.json | 2 +- src/component/RawLogger.tsx | 8 ++++---- src/model/ErrorContext.ts | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3a8f753..80add6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-ansi", - "version": "2.0.0", + "version": "2.0.1", "description": "", "author": "RaoHai", "license": "MIT", diff --git a/src/component/RawLogger.tsx b/src/component/RawLogger.tsx index 0f719b3..c24ea5a 100644 --- a/src/component/RawLogger.tsx +++ b/src/component/RawLogger.tsx @@ -167,7 +167,7 @@ export function Line({ linkify: boolean; index: number, }) { - const { addRefs } = useContext(ErrorContext); + const { setErrorRefs } = useContext(ErrorContext); const { errors, content } = useMemo(() => { return ansiToJSON(line).reduce((prev, bundle, index) => { const content = convertBundleIntoReact(useClasses, linkify, bundle, index); @@ -186,11 +186,11 @@ export function Line({ useEffect(() => { if (errors.length && ref.current) { - if (errors.length && addRefs) { - addRefs(errors, ref.current); + if (errors.length && setErrorRefs) { + setErrorRefs(errors, ref.current); } } - }, [ref, errors, addRefs]); + }, [ref, errors, setErrorRefs]); return (
diff --git a/src/model/ErrorContext.ts b/src/model/ErrorContext.ts index 7a38bba..b480fda 100644 --- a/src/model/ErrorContext.ts +++ b/src/model/ErrorContext.ts @@ -3,13 +3,15 @@ import { createContext } from 'react'; const errorRefs = new Map(); -export function addRefs(errors: ErrorMatcherPattern[], ref: HTMLDivElement) { +export function setErrorRefs(errors: ErrorMatcherPattern[], ref: HTMLDivElement) { + errorRefs.clear(); errorRefs.set(ref, errors); } + export { errorRefs }; export const ErrorContext = createContext({ refs: errorRefs, - addRefs, + setErrorRefs, });