L
L
Lite_robot2017-03-10 16:08:05
JavaScript
Lite_robot, 2017-03-10 16:08:05

React.js: Why might a component not render?

Hi
there are a couple of components:
MessageList
pastebin.com/XNs3a3kv

import React, {Component} from 'react';
import Message from './Message.jsx';

export default class MessageList extends Component{
    render(){
        return (
        <div className="message-list">
            {
                this.props.asd.map((cur) => {
                    return (
                        
                        <Message id={cur.id} text={cur.text}/>

                    );
                })
            }

        </div>
    );
    }
}

Message
pastebin.com/3Qv0E2Bi
import React, {Component} from 'react';



export default class Message extends Component {
    render() {
        console.log(this.props);
        return (
            <div key={this.props.id} className="row" style={{borderBottom: 'solid black 1px'}}>
                <div className="col-lg-11">
                    {this.props.text }
                </div>
                <div className="col-lg-1">
                    {(new Date()).toLocaleTimeString()}
                </div>
            </div>
        );
    }
};

When you include a Message in a MessageList, the Message component is not displayed. But if instead of including the Message, write the code from the Message, then everything is displayed as it should. Can you tell me what could be wrong and how to fix it?
upd.#1
Both components are in the same folder. console.log in the Message component is not displayed in the console. Let me remind you that when you transfer code from Message to MessageList , the data is displayed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lite_robot, 2017-03-12
@Lite_robot

The problem was in running Firebug. I do not know how it affects, but with Firebug turned off, everything is rendered.

M
Maxim, 2017-03-10
@maxfarseer

Also (plus what you have already been answered), it is possible that the ./Message.jsxexport default is incorrect in the component.
If export is specified there without default , then it means that you need to import with curly braces, and the name in the import must match the name in the export. (e.g. import { Message } from ... )
ps attach the code of the Message component

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question