I am using Webpack, Redux and ReactJS.
Currently I have the following set up in my index.html but I want to convert it to JSX, ReactJS Component. What's the proper and correct way to do so?
And in my index.html <head/>, have a class helper functions called classie.js:
<script src="classie.js"></script>
<script>
function init() {
window.addEventListener('scroll', function(e){
var distanceY = window.pageYOffset || document.documentElement.scrollTop,
shrinkOn = 300,
header = document.querySelector("header");
if (distanceY > shrinkOn) {
classie.add(header,"smaller");
} else {
if (classie.has(header,"smaller")) {
classie.remove(header,"smaller");
}
}
});
}
window.onload = init();
</script>
And in my index.html <body/>:
<div id="wrapper">
<header>
<div class="container clearfix">
<h1 id="logo">
Practice Navigation Bar
</h1>
<nav>
<a href="">Button 1</a>
<a href="">Button 2</a>
</nav>
</div>
</header>
</div>
So convert it into like the following ReactJS component format:
//App.js
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import actions from '../redux/actions'
class NavBar extends Component {
render() {
return (
<div>
{/*e.g. What should go in here?*/}
</div>
);
}
}
function mapStateToProps(state) {
return state
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(actions, dispatch)
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(NavBar)
Thank you in advance!