Guest User

Untitled

a guest
Jan 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import React, { Fragment, Component } from 'react';
  2. import ReactMarkdown from 'react-markdown';
  3.  
  4. import source from './posts/2018-01-08.md';
  5.  
  6. class WhatsNew extends Component {
  7. state = {
  8. post: null,
  9. }
  10.  
  11. componentDidMount() {
  12. fetch(source)
  13. .then(res => res.text())
  14. .then(post => this.setState((state) => ({ ...state, post })))
  15. .catch((err) => console.error(err));
  16. }
  17.  
  18. render() {
  19. const { post } = this.state;
  20.  
  21. return (
  22. <Fragment>
  23. <section className="hero">
  24. ... header stuff
  25. </section>
  26. <section className="section">
  27. <div className="container">
  28. <div className="card">
  29. <div className="card-content">
  30. <div className="content">
  31. <ReactMarkdown source={post} />
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </section>
  37. </Fragment>
  38. );
  39. }
  40. }
  41.  
  42. export default WhatsNew;
Add Comment
Please, Sign In to add comment