D
D
Dmitry Arushanov2016-04-25 15:28:25
React
Dmitry Arushanov, 2016-04-25 15:28:25

How to pass object to child component?

I'm using React in an angular app with ngreact.
The component structure is as follows:

<Parent>
  <Child1>
    <Child1.1></Child1.1>
    <Child1.2></Child1.2>
  </Child1>
  <Child2>
    <Child2.1></Child2.1>
    <Child2.2></Child2.2>
  </Child2>
</Parent>

In angular, when switching to state in resolve, I receive data and in the controller I assign them to the osprey variable on the view . In the Parent component, I receive this data transmitted by demonic problems. From Parent I try to pass them below to Child1
$scope. someVar = {someData: dataFromresolve};
<react-component props="someVar" name="Parent"/>

...
render: function () {
                    return (
                        <Child1 someProps={this.props.someData}></Child1>
                   );
                }
...

And I get the error Error: Objects are not valid as a React child (found: object with keys .....

So how do I pass this data to child components?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-04-25
@daruwanov

You are trying to render React child as an object somewhere, something like this:

let data = {'a': <div>1</div>,'b':<div>2</div>}
<li>{data}</li>

The data variable must be an array.

G
gracer, 2015-05-05
@Urukhayy

SELECT t1.*, t2.value FROM table1 t1 
    LEFT JOIN table2 t2 ON t2.id = t1.id 
ORDER BY t1.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question