react-case-study-presentation



react-case-study-presentation

0 0


react-case-study-presentation


On Github bassettsj / react-case-study-presentation

React Investigation

notes: From the terminal, pop in:

yo reveal:slide "Slide Title"

Available options:

--markdown --attributes --notes

What is React?

React is a JavaScript library for creating user interfaces by Facebook and Instagram. Many people choose to think of React as the V in MVC.

We built React to solve one problem: building large applications with data that changes over time.

Why React - Facebook

How does it work?

Maintains a "Virtual DOM" On changes, it creates a diff Applies the changes in batches to the DOM

Pros

"We built React to solve one problem: building large applications with data that changes over time."

Simple

Simply express how your app should look at any given point in time, and React will automatically manage all UI updates when your underlying data changes.

Declarative

When the data changes, React conceptually hits the "refresh" button, and knows to only update the changed parts.

Build Composable Components.

React is all about building reusable components. In fact, with React the only thing you do is build components. Since they're so encapsulated, components make code reuse, testing, and separation of concerns easy.

Just the V in MVC

React does one thing very well, it manages updating the state of the view. Because you can just use this, it is Relatively easy to integrate into other frameworks.

Popularity

Support from some of the largest companies in the valley and a thriving open-source community. Support continues to grow for it every day.

Server Side Rendering

Since react is able to represent the DOM virtually, it is able to render app state server side and be able to then take the current UI state and manage it as a SPA after the client has loaded. This allows for better SEO, performance and progressive enhancement.

Developer Productivity

Because of the large amount of tooling that supports react, and the focus on simplicity in build react components, it can make building large applications much easier for developers.

Cons

Need to learn something new. React is best used in a flux architecture. Writing HTML in JS is weird at first.

Integration Ideas

Use React Components in Backbone View Classes Use React components as the view class themselvesnavigator-js injector-js Use flux for greenfield applications and use bridging libraries to fill in the services.backbone-redux
Use React Components in Backbone View Classes
export default BaseView.extend({
    initialize(options = {}) {
        this.head = options.head || [];
        this.rows = options.rows || [];
        this.sort = options.sort || true;
    },
    render() {
        ReactDOM.render(
            <Table data={ this.mapToData() } sortable= { this.mapToSort() } />,
            this.el
        );

        return this;
    }
});
Use React Components as View Class
function mapStates() {
    _appContext.stateViewMap
        mapState(States.ALL.STATES)
        .toView(ReactComponent)
}
navigator-js injector-js
Using redux in new "apps"
// App an non-backbone responder to the initialize
// Add redux store for data with adapter for backbone
let _initialized = false;
let _injector;
let _njs;
let _appContext;

class GettingStartedApp extends Component {
    render() {...}
}

class GettingStartedRoot extends Component {
    render() {
        return (
            <Router history={this.props.history}>
                <Route path='/' component={GettingStartedApp}>
                    ...
                </Route>
            </Router>
        );
    }
}

export function init(injector) {
    if (_initialized) {
        return;
    }
    _injector = injector;
    const urlSyncer = _injector.getInstance('urlSyncer');
    urlSyncer.dispose();
    const njs = injector.getInstance('njs');
    _appContext = _injector.getInstance('appContext');
    render(<GettingStartedRoot history={njs.history}/>, document.querySelector('[data-app-buffered]'));
    _initialized = true;
}

Questions & Next Steps

Let's discuss.