Skip to content

Commit

Permalink
feat: version to 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Sep 4, 2020
1 parent 593f94b commit 58bbe98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-ansi",
"version": "2.0.0",
"version": "2.0.1",
"description": "",
"author": "RaoHai",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions src/component/RawLogger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 (
<div className={`${styles.logLine} ${errors.length ? styles.error : ''}`} key={index} ref={ref}>
Expand Down
6 changes: 4 additions & 2 deletions src/model/ErrorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { createContext } from 'react';

const errorRefs = new Map<HTMLDivElement, ErrorMatcherPattern[]>();

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,
});

0 comments on commit 58bbe98

Please sign in to comment.