Steven Seagull Steven Seagull - 1 month ago 10
React JSX Question

React JS include header

So I'm new to React JS and currently I need some information about how to include HTML from another file to current file. For example in PHP I would have an index.php file and a header.php file.

In header.php file I would write a html code for my page's header, and then this header would be included in index.php by doing:

<?php include 'header.php'; ?>

How can I do the same with React JS?

Having a component with
<Header /><Body />
just doesn't look ok to me.

  1. You dont have HTML in ReactJS, what you have is HTML-like syntax called JSX.
  2. You can include a React component into another component in a few different ways:

import Header from 'Header'

import * as Header from './Header'

import {abc} from './Header'

require('Header') also works.