hegibo2346
hegibo2346

Reputation: 41

How to fetch WordPress api with all the styling not just plain text with React

So I want to use React to fetch blog posts from WordPress, but when I do so, all the styling is lost and I get only JSON plain text which is neither formated nor styles with h1, no images, and vice versa, what is the solution to this problem?

Upvotes: 0

Views: 415

Answers (1)

keyhan
keyhan

Reputation: 522

Using graphql you can query enqueuedStylesheets over posts

    query MyQuery {
      posts {
         nodes {
                  enqueuedStylesheets {
                     nodes {
                           src
                     }
                  }
        }
      }
    }

And you can add styles to your react page with react-helmet.

<Helmet>
   <link rel="stylesheet" type="text/css" href="style.css" />
 </Helmet>

Upvotes: 1

Related Questions