Reactredux
Reactredux
Nik Graf
@nikgraf
Source: https://www.flickr.com/photos/mike52ad/
React
• Virtual DOM
Source: http://teropa.info/blog/2015/03/02/change-and-its-detection-in-javascript-frameworks.html
Source: http://teropa.info/blog/2015/03/02/change-and-its-detection-in-javascript-frameworks.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script src="bundle.js"></script>
</head>
<body>
<div id="example"></div>
</body>
</html>
index.html
// Input (JSX):
var app = <Nav color="blue" />;
// Output (JS):
var app = React.createElement(Nav, {color:"blue"});
<body>
<div id="example">
<p> <!-- App start -->
Hello World!
</p> <!-- App end -->
</div>
</body>
index.html
profile.js
<body>
<div id="example">
<div> <!-- App start -->
<h1>Hello World!</h1>
<div> <!-- Profile start -->
<img src="http://test.png" />
<span>Nik</span>
</div> <!-- Profile end -->
</div> <!-- App end -->
</div>
</body>
index.html
easy to understand
&
easy to test
React + Redux @nikgraf
React + Redux @nikgraf
If/Else
const Profile = ({name, isOnline}) => {
let onlineIndicator;
if (isOnline) {
onlineIndicator = (<span>green</span>);
} else {
onlineIndicator = (<span>red</span>);
}
return (
<div>
{name} {onlineIndicator}
</div>
);
} profile.js
<div>
Nik <span>red</span>
</div>
friendlist.js
<ul>
<li>Max</li>
<li>Tom</li>
</ul>
profile.js
Source: https://twitter.com/codecartoons/status/667348216669741056
React
Components
Interaction e.g onClick
const action = {
type: 'ADD_TODO',
text: 'Call Mom',
}
store.subscribe(() =>
console.log(store.getState())
)
- Reusable Components
- TimeTravel
Redux
Source: http://www.wolfography.at/
The End
Thanks for listening!
https://github.com/nikgraf
https://twitter.com/nikgraf
http://www.meetup.com/Vienna-ReactJS-Meetup/