Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtonG committed Aug 22, 2024
1 parent 6f47fad commit 92a5e4a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kit/CodeEditor/IpynbRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const parseNotebook = (file: string): string => {
};

const JupyterRenderer: React.FC<Props> = React.memo(({ file, onError }) => {
// parse the file and store the result as either a successful string or a failed error
const parseResult = useMemo(() => {
return tryCatch(
() => parseNotebook(file),
Expand All @@ -27,6 +28,7 @@ const JupyterRenderer: React.FC<Props> = React.memo(({ file, onError }) => {
}, [file]);

useEffect(() => {
// if the parse result is failed, call the error handler
pipe(
parseResult,
mapLeft((e) => {
Expand All @@ -40,6 +42,7 @@ const JupyterRenderer: React.FC<Props> = React.memo(({ file, onError }) => {
);
}, [parseResult, onError]);

// if the parse result is failed, fall back to the raw file, otherwise show the parse result html
return pipe(
parseResult,
match(
Expand Down

0 comments on commit 92a5e4a

Please sign in to comment.