Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show React code in Github Markdown

I'm trying to create a React tutorial on Github, but I'm having issues with getting the Github formatting to line up with what I want to display. I would like to display this code:

```JavaScript
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class Child extends Component {
  render() {
    return (
        <p className="App-intro">
          I'm a childish component
        </p>
    );
  }
}

export default Child;
```

But on Github, it is appearing like this:

enter image description here

Is the single quote the problem? Is Github unable to rend React because of the JavaScript/HTML mix?

like image 950
Luke Schlangen Avatar asked Oct 16 '17 20:10

Luke Schlangen


1 Answers

Use JSX for the language:

```JSX
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class Child extends Component {
  render() {
    return (
        <p className="App-intro">
          I'm a childish component
        </p>
    );
  }
}

export default Child;
```

Should render correctly

like image 118
Chase DeAnda Avatar answered Oct 21 '22 22:10

Chase DeAnda