0

I'm building a basic view article component, backed by a Rails API. The API unfortunately returns html, which is what my component will display.

Now, I need to build some features that will require me to have some control over the html response. For example, i need to be able to attach react bindings to the anchor tags in the response.

Anyone have experience with this type of problem or have any suggestions?

am80l
  • 1,511
  • 12
  • 11
  • All I know is [don't parse HTML with a regex](http://stackoverflow.com/a/1732454/1896761). – Austin Mullins Oct 22 '15 at 22:12
  • 1
    React doesn't work with HTML, it works with JS objects (which can be generated via JSX). You'll either have to convert the HTML to JS objects (there are some libraries that attempt to do this) or manage the HTML interactivity yourself. – Michelle Tilley Oct 23 '15 at 00:43
  • 1
    Thanks @BinaryMuse, I did try experimenting with converting the html to React descriptors but it was really a pain and the tools weren't really up to par. In the end I went with a few lines of javascript to do the DOM manipulations/bindings manually on componentWillUpdate(). It didn't feel exactly like the "React way" to do it, but solved my issue sufficiently. – am80l Oct 23 '15 at 23:37

0 Answers0