JSX没有按预期方式吐出HTML

时间:2018-03-02 17:35:21

标签: javascript html reactjs frontend jsx

我有代码

import _ from 'lodash';
import {Link} from 'react-router';
import React, {Component} from 'react';

class Categories extends Component {
renderCategory(category, categoryIndex) {
    return (
        <div>{category}</div>
    );
};

renderCategories() {
    return _.map(this.props.categories, (category, categoryIndex) => {
        console.dir(category);
        this.renderCategory(category, categoryIndex);
    });
}

render() {
    console.dir(this.props.categories);
    return (
        <div>
            {this.renderCategories()}
        </div>
    );
}
}


export default Categories;

我正在调用另一个这样的组件:

<Categories categories={{'an-example': "another"}}/>

现在我没有关联HTML响应,但是控制台日志确实出现了:

Object
an-example: "another"__proto__: Object
bundle.js:46448 another

我缺少什么?如何在DOM中打印div?提前谢谢!

0 个答案:

没有答案