を反応させるの小道具をレンダリングするために反応し、このようになりますどのarea
呼ば:は、私が現在使用している
[{
"id": 1,
"name": "Europe",
"Countries": [{
"id": 1,
"name": "Iceland",
"Cities": [{
"id": 1,
"name": "Selfoss"
}]
}, {
"id": 2,
"name": "Switzerland",
"Cities": [{
"id": 2,
"name": "Geneva"
}]
}]
}, {
"id": 2,
"name": "Asia",
"Countries": [{
"id": 3,
"name": "Japan",
"cities": [{
"id": 3,
"name": "Yokohama"
}]
}]
}]
UPDATE 2--
このWORKSを:
class AreaBar extends Component {
constructor(props) {
super(props);
}
.....
renderCountries() {
return(
<div>
This is the country
</div>
)
}
renderContinents() {
return(
<div>
This is the continent
{this.renderCountries()}
</div>
)
}
render() {
return(
<div>
{this.renderContinents()}
</div>
);
}
}
この出力:
マップを組み込む、このが
renderContinents(area) {
return(
<div>
{area.name}
</div>
)
}
render() {
return(
<div>
{this.props.areas.map(this.renderContinents)}
</div>
);
}
}
この出力WORKS:
Europe
Asia
しかし私は{this.renderCountries()}
を含む場合、それは私がなぜだと思う何も出力、しませんが働くための提案を得ることができませんでした。 Firefoxのオン
renderCountries() {
return(
<div>
This is the country
</div>
)
}
renderContinents(area) {
return(
<div>
{area.name}
{this.renderCountries()}
</div>
)
}
render() {
return(
<div>
{this.props.areas.map(this.renderContinents)}
</div>
);
}
}
大陸の両方が現れたが、その代わり、私はrenderCountriesを実行することはできませんと言っているように思え
unreachable code after return statement
When an expression exists after a valid return statement,
a warning is given to indicate that the code after the return
statement is unreachable, meaning it can never be run.
を得る「この国では表示されません」。私はまだこれについて少し混乱していますが、私はコンポーネントを分けて問題を修正しようとしていると思います。
'.map'は' Object'のものではなく 'Array'メソッドです。どういう意味ですか?「うまくいきません」とはどういう意味ですか? – martriay
@martriay私はコンソールに何のエラーも表示されませんが、何も表示されません。また、[object、object]はオブジェクトを持つ配列なので、.mapはこれで動作しませんか? – lost9123193