React and Redux
Lars Thorup, Triggerz
August, 2016
Lars Thorup
● Software developer/architect
● JavaScript, C#
● Test Driven Development
● Coach
● Agile engineering practices
● Founder
● BestBrains
● ZeaLake
● Triggerz
● @larsthorup
Agenda
● Our current MVP architecture
● React
● Diagram
● Demo: <Signin />
● D3
● Discussion
● Redux
● Diagram
● Code
● Discussion
● create-react-app
MVP architecture
JavaScript
React
Redux
Ramda
Webpack
CSS
Node.js
Restify
Knex
Cryptex
Co
PostgreSQL
● Demo!
Ajax &
WebSockets
SQL
React - Diagram
React - Demo
<Signin signingIn={({account}) => alert(account)}/>
// ----
render () {
return (
<form onSubmit={this.onSubmit}>
<input type="text" onChange={this.onChange}/>
<button type="submit">Sign In</button>
</form>
);
}
https://github.com/larsthorup/react-signin-sample
React - Discussion
● Mandatory
● Virtual DOM - decoupled from browser DOM
● Avoid
● HTML, browser DOM, jQueue, D3?
● Optional
● ES6
● JSX
● Webpack
● Stateful and stateless components
● Server-side rendering
● Routing
React - D3
● Competing DOM
manipulation
● We use plain SVG
● And CSS transforms
● Example: gauge.js
● A react-friendly D3?
Redux - Motivation
● Distributed state ● Centralized state
Redux - Overview
Redux - Examples
● State shape
● Auth reducers
● Auth saga: signingIn
Redux - Discussion
● Design patterns
● command
● singleton
● same data flow as server side pages before Ajax!
● Modularity
● State shape
● Testability
● Higher-order functions
● connect(mapStateToProps)(Component)
create-react-app
$ npm install -g create-react-app
$ create-react-app my-first-app # takes 5 min(!)
$ cd my-first-app
$ npm start
# ToDo: hack my-first-app
# https://github.com/larsthorup/react-signin-sample
Questions!

Lars thorup-react-and-redux-2016-09