StephenGrider / ReactCasts

App by app code for Build Web Apps with React JS
585 stars 244 forks source link

react 0.14 - Flux - 11 - Fetching Data Naively #6

Open sergeybataev opened 9 years ago

sergeybataev commented 9 years ago

Console log: Uncaught (in promise) Error: Invariant Violation: Objects are not valid as a React child (found: object with keys {id, name, description, css, ephemeral, readonly}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of exports.

(anonymous function) @ topicList.jsx:13

sergeybataev commented 9 years ago

it's may be not a good solution, but works:

                this.setState({
                    topics: data.data.map(
                        function(topic,key) {
                            return createFragment(topic)
                        }
                    )
                })

any suggestions?

ekarni commented 8 years ago

I'm having the same issue, but for me createFragment isn't even a function. I'll be happy to hear if you've found a better solution for this issue. Thanks!

linesight commented 8 years ago

use topic.name instead of topic in

    renderTopics: function() {
        return this.state.topics.map(function(topic) {
            return <li>
            {topic.name}
            </li>
        })
    }