Skip to content

Loading markdown #3025

Closed
Closed
@kennetpostigo

Description

@kennetpostigo

Hey,

So I'm building a simple doc site at the moment and using CRA for this. I'm using react-markdown which depends on json-loader to do it's job. json-loader is enabled by default in webpack 2+ so CRA should work without a problem, but instead of printing the contents as it should I get the following printed out:
/static/media/path.e4d613b6.md

thats the path to the markdown file.

This is the code importing the markdown:

const loadMd = m => {
  var Markdown = asyncMarkdown(() =>
    import(`./../markdown/${m}.md`).then(
      module => console.log(module),
      err => console.log(err)
    )
  );
  return <loadMd />;
};

function Content(props) {
  return (
    <div>
      {loadMd("path")}
    </div>
  );
}

I've used this same code and it works outside of CRA so I'm not exactly sure why it is loading the path now instead of the content. Any clues?

Activity

viankakrisna

viankakrisna commented on Aug 29, 2017

@viankakrisna
Contributor

Hi! You can use fetch instead of dynamic import to read the contents of the file. Read more here #2961 (comment)

gaearon

gaearon commented on Jan 9, 2018

@gaearon
Contributor

New thoughts on how we could handle this: #3722.

locked and limited conversation to collaborators on Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gaearon@kennetpostigo@viankakrisna

        Issue actions

          Loading markdown · Issue #3025 · facebook/create-react-app