Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

React: render the component

0 votes
96 views
added Aug 18, 2017 in React by LC Marshal Captain (20,510 points)
edited Jul 13, 2018 by LC Marshal

Example directory: 

  • Yoursite/template/layout/index.html
  • Yoursite/js/app.js
  • Yoursite/js/components/header/header.js

Index.html

<body>
   <header id="header"></header>
</body>

app.js

import Header from './components/headers/header'

window.addEventListener('DOMContentLoaded', () => {
const project_store = new Project()

if($('#header').length) {
ReactDOM.render(<Header />, document.getElementById('header'))
}
})

header.js

import { Component } from 'react'
class Header extends Component {
  render() {
  return (
    <div>
      Header element goes here
    </div>
  )
  }
}
module.exports = Header

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...