From 5abf2d02bd4d11097b2650861195cf605e42bbf7 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 5 Apr 2020 16:32:44 +0300
Subject: fix: update markdown on hook

---
 src/lib/Markdown/Markdown.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src/lib/Markdown/Markdown.tsx')

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')} />
 };
-- 
cgit v1.2.3

