aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Markdown/Markdown.tsx7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/Markdown/Markdown.tsx b/src/lib/Markdown/Markdown.tsx
index aee96e9..09ad54a 100644
--- a/src/lib/Markdown/Markdown.tsx
+++ b/src/lib/Markdown/Markdown.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import axios from 'axios';
import Section from './Section';
@@ -10,6 +10,11 @@ interface PropTypes {
const Markdown: React.FC<PropTypes> = ({ data, url }) => {
const [markdown, setMarkdown] = useState<string>(data || '');
+
+ useEffect(() => {
+ if (!url) setMarkdown(data || '');
+ }, [data, url]);
+
if (url) axios.get(url).then(response => setMarkdown(response.data));
return <Section rawLines={markdown.split('\n')} />
};