title: How to read local text file in reactjs?
body: <p>I am creating a react website by <code>create-react-app</code>. I have some markdown files in current directory. I want to preview them in the website (like github shows markdown files in preview format). I've found markdown previewer <code>ReactMarkdown</code>. Now the only code I need is a React functional/class component that will read markdown files. I've tried some solutions in stackoverflow but none of them worked.</p>
  <p>This is my <strong>App.js</strong></p>
  <pre><code>import ReactMarkdown from 'react-markdown';
  import ReadFileData from './ReadFileData';
  import data from './file.md'; 
  // const data = require('./file.md');
  import './App.css';
  
  function App() {
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;ReactMarkdown&gt;&lt;ReadFileData data={data}/&gt;&lt;/ReactMarkdown&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  
  </code></pre>
  <p>I've wrote a small part of <strong>ReadFileData.js</strong>. But I don't know how to complete it.</p>
  <pre><code>import React from &quot;react&quot;;
  
  class ReadFileData extends React.Component {
  
    render(){
  
      const unparsed = this.props.data;
  
      console.log(unparsed);
  
  //  The code I need
  
      const readAbleData = &quot;unknown&quot;;
  
      return(
          &lt;div&gt;
              &lt;p&gt;{readAbleData}&lt;/p&gt;
          &lt;/div&gt;
      );
    }
  }
  
  export default ReadFileData;
  </code></pre>