2

I've tried to render a simple component but cant seem to make it work.

<Col md={{ span: 16, offset: 4 }} xs={{ span: 20, offset: 2 }}>
    {props.language === "en" ? <englishReport /> : <danishReport />}
</Col>

This is what <englishReport/> component and <danishReport/> looks like

import React, { Component } from 'react';

class indexDanish extends Component {
    render() { 
        return ( 
             <div style={{ color: "#fff", textAlign: "left" }}>
                 <b>hej</b>
             </div>
         );
    }
}

export default indexDanish;

I have imported both components in the parent component

0

1 Answer 1

6

A custom component name needs to start with a capital letter, or Babel will treat that as a string.

Change the englishReport and danishReport names to EnglishReport and DanishReport and it will work.

<Col md={{ span: 16, offset: 4 }} xs={{ span: 20, offset: 2 }}>
  {props.language === "en" ? <EnglishReport /> : <DanishReport />}
</Col>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.