1

I'm using react 16.2.0 and react-dom 16.2.0. Following is the code I have.

import React, { Fragment } from 'react';

import BodyComponent from './BodyComponent';
import * as HeaderComponents from './HeaderComponent';


class TablePage extends React.Component {
    constructor(props) {
        super(props);
    }


    render() {

        const MyHeader = (props) => {
            const Header = HeaderComponents.TableHeader;
            return <Header status={props.status}/>;
        };



        let pageContent = null;



            pageContent = (
                <ul className="list-table" role="table" aria-label={MessageConstants.ASSIGNMENT_ITEMS_TABLE_CAPTION_MESSAGE}>
                    <MyHeader status={status}/>
                    {
                        items.map((item, i) => {
                            return <TableBody dataSet={item} key={i}/>;
                        })
                    }
                </ul>
            );


        return (pageContent);
    }
}

class TableBody extends React.Component {
    constructor(props) {
        super(props);

    }


    render() {
        const {dataSet} = this.props;


        const BodyHeader = (props) => {
            const Header = HeaderComponents.BodyHeader;
            return <Header index={this.props.index}/>;
        };


        return (
        <Fragment>
         <BodyHeader index={this.props.index}/>
         <BodyComponent itemList={dataSet.content}/>
        </Fragment>
        );
    }
}

export default TablePage;

My problem is, the components I'm returning inside are not rendering. I don't get any errors in the console as well.

I tried rendering simple html code such as

<Fragment>
    <p>foo</p>
    <p>bar</p>
</Fragment>

But the issue remains. Can someone please help me with this.

  • Do you get any error, Also try `return pageContent;` and make sure you are passing items as prop to TablePage – Shubham Khatri May 10 '18 at 12:11
  • You are not passing `index` as a prop to the `TableBody` which tries to pass it down to the `BodyHeader` – Gabriele Petrioli May 10 '18 at 12:21
  • Thank you for your replies. If the issue is in prop passing, then it makes sense because the components such as BodyHeader and BodyComponent are expecting props. But why is it that simple html fragments which do not need props such as

    foo

    and

    bar

    aren't getting printed?
    – Sarani Mendis May 11 '18 at 08:29

0 Answers0