entelect logo

BEE123 React Migration

Upgrading our Front End

8 Aug 2019

Entelect + BEE123
BEE123 React Migration

Current front end

Durandal
Knockout

Entelect + BEE123
BEE123 React Migration

Options

  • Angular
  • Aurelia
  • React
Entelect + BEE123
BEE123 React Migration

We chose React

React
Entelect + BEE123
BEE123 React Migration

Why React

  • We have some React developers
  • React is not a Framework
  • React is component based
Entelect + BEE123
BEE123 React Migration

Current UI e.g.

Scorecard Summary
Entelect + BEE123
BEE123 React Migration

Our Crazy Plan

Scorecard Summary
Entelect + BEE123
BEE123 React Migration

Goals for React components

  • Use latest JS features
  • Write real React components
  • Create a bundle that we can deploy seperately
  • Call React components from HTML
Entelect + BEE123
BEE123 React Migration

Code ahead

warning
Entelect + BEE123
BEE123 React Migration

ReactDom Render


 const domContainer = document.querySelector('#like_button_container');
 ReactDOM.render(e(LikeButton), domContainer);
    
Entelect + BEE123
BEE123 React Migration

Proof of Concept

component

export class CoolButton extends React.Component {
	render() {		
		return (
			<>
				<h1>tester</h1>
				<button className="coolButton" onClick={this.props.sayHello}>
					{ this.props.title ? this.props.title : 'Yello' }
				</button>
			</>
		);
	}
}
Entelect + BEE123
BEE123 React Migration

Proof of Concept

registering a component

import { register } from 'web-react-components';
import { CoolButton } from "./components/CoolButton/CoolButton.js";
//
register(CoolButton, 'bee123-coolbutton', ['title', 'sayHello()']);
Entelect + BEE123
BEE123 React Migration

Proof of Concept

use in html


<bee123-coolbutton title="yes" sayHello="alert('tester')"></bee123-coolbutton>
<bee123-coolbutton></bee123-coolbutton>
    
Entelect + BEE123
BEE123 React Migration

Proof of Concept

Working example

Entelect + BEE123
BEE123 React Migration

Storybook

For development

storiesOf('CoolButton', module)
  .add('default', () => (
      <CoolButton />
    )
); 
Entelect + BEE123
BEE123 React Migration

Storybook

For development

storiesOf('CoolButton', module)
  .add('with CallBack', () => (
      <CoolButton 
        title="Super Duper Cool"
        sayHello={() => {
            alert('hello there');
        }}
      />
    )
); 
Entelect + BEE123
BEE123 React Migration

End