Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
React & Redux @ Grillcon 2017
Search
Mattias Lyckne
September 15, 2017
Programming
0
61
React & Redux @ Grillcon 2017
React & Redux talk from Grillcon 2017
Mattias Lyckne
September 15, 2017
Tweet
Share
Other Decks in Programming
See All in Programming
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
230
すべてのコンテキストを、 ユーザー価値に変える
applism118
3
1.2k
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
160
Node-RED を(HTTP で)つなげる MCP サーバーを作ってみた
highu
0
120
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
700
PicoRuby on Rails
makicamel
2
120
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
480
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
810
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
700
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
430
Deep Dive into ~/.claude/projects
hiragram
13
2.4k
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
3
450
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
39k
A Modern Web Designer's Workflow
chriscoyier
694
190k
Stop Working from a Prison Cell
hatefulcrawdad
270
21k
What's in a price? How to price your products and services
michaelherold
246
12k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Building Applications with DynamoDB
mza
95
6.5k
Building Adaptive Systems
keathley
43
2.6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
730
Measuring & Analyzing Core Web Vitals
bluesmoon
7
500
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
GitHub's CSS Performance
jonrohan
1031
460k
Transcript
React & Redux
Web, internet och programvaruteknik Winterkvist.com Prisjakt Mattias Lyckne
React
” A Javascript Library for buidling user interfaces
Learn Once, Write Anywhere
React React Native React Native Windows React Native for web
React VR React Hardware React PDF Learn Once, Write Anywhere React DocX React Sketchapp React Blessed Spectacle and much more
None
function Text(props) { return <p>{props.text}</p>; }
import React from 'react'; class Text extends React.Component { render()
{ return <p>{this.props.text}</p>; } }
import React from 'react'; import Text from './text'; import ReactDOM
from 'react-dom'; ReactDOM.render( <Text text="Hello Grillcon!" />, document.getElementById('root') );
import React from 'react'; class TextInput extends React.Component { constructor(props)
{ super(props); this.state = { text: props.text }; } handleChange(evt) { this.setState({text: evt.target.value}); } render() { return ( <div> <input onChange={this.handleChange} value={this.state.text} /> <p>{this.state.text}</p> </div> ); } }
Internal state Lifecycle methods Stateful component No internal state No
lifecycle methods Stateless component
DEMO
None
Redux
” Redux is a predictable state container for JavaScript apps.
Actions Redux Reducers Store
Payload of information you send to the store. Actions {
type: 'SAVE_SEARCH', query: 'Playstation' }
Function that creates an action Action creators function saveSearch(query) {
return { type: 'SAVE_SEARCH', query: query, }; }
Take an action and specify how the application states changes.
Reducers function reducer(state, action) { if (action.type === 'SAVE_SEARCH') { return { ...state, savedSearches: state.savedSearches.concat(action.query) }; } return state; }
Brings the actions and reducers together. Holds the application state.
Store
1. store.dispatch(action); 2. Redux store calls the reducer 3. Redux
store saves the state returned by the root reducer Redux flow
yarn add redux react-redux Install
DEMO
None
What about side effects?
Aims to make side effects easier and better Redux Saga
Testing
Easy setup Instant feedback Snapshots Jest React Testing Utility jQuery-like
API to manipulate and traverse React components Enzyme
import { shallow } from enzyme; import SaveSearch from '../save-search';
describe('SaveSearch', () => { it('renders without crashing', () => { shallow(<SaveSearch />); }); it('calls function on onClick', () => { const func = jest.fn(); const wrapper = shallow(<SaveSearch onClick={func} />); wrapper.find('button').simulate('click'); expect(func).toHaveBeenCalled(); }); });
yarn create react-app yarn add redux react-redux yarn add --dev
redux-devtools yarn add --dev enzyme react-test-renderer Start coding
Questions?
[email protected]
@MattiasLyckne
None