diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-04-05 22:49:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 22:49:24 +0300 |
commit | ffa56075c7f92ee0e3a5143fbf2e506eba016143 (patch) | |
tree | 50ec8eee86570cf3cadfa26c73f25c50334f1543 /src/lib/Markdown/Markdown.tsx | |
parent | 0a73e37b1bc78fead6a78722568532c327127b54 (diff) | |
parent | e9c6eb6be709db76002c41e5bf7d13654493d0a8 (diff) | |
download | react-benzin-ffa56075c7f92ee0e3a5143fbf2e506eba016143.tar.gz |
Merge pull request #7 from eug-vs/markdown
Markdown proof of concept
Diffstat (limited to 'src/lib/Markdown/Markdown.tsx')
-rw-r--r-- | src/lib/Markdown/Markdown.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/Markdown/Markdown.tsx b/src/lib/Markdown/Markdown.tsx new file mode 100644 index 0000000..09ad54a --- /dev/null +++ b/src/lib/Markdown/Markdown.tsx @@ -0,0 +1,24 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; + +import Section from './Section'; + +interface PropTypes { + data?: string; + url?: string; +} + +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')} /> +}; + + +export default Markdown; + |