Closed tauseefk closed 8 years ago
+1
+1
The encoded JSON in the above example is an array. setComponent
will pass that directly to React.createElement
as the props, which are expected to be an object, not an array. It looks like your component expects a data
prop, so your JSON should have that as a key.
Actually your component isn't expecting a data
prop but a url
prop, which will then be used to do xhr and get data. Your component doesn't have a way to accept data via props. So you have more work to do to make this play nicely (you could take a data
prop which then gets stored into state).
We've been trying to use this with Cake php. So far I've had no luck in pushing the json data into the component and then render it. The code looks somewhat like this:
index.ctp looks like this
The js file looks like
I want to use ReactDOMServer.renderToString with this, but there's no way that I can currently do that. cc @stoyan