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
高速開発のためのコード整理術
sutetotanuki
1
400
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
180
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
Basic Architectures
denyspoltorak
0
680
CSC307 Lecture 05
javiergs
PRO
0
500
SourceGeneratorのススメ
htkym
0
200
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
210
MUSUBIXとは
nahisaho
0
130
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
14k
A Tale of Four Properties
chriscoyier
162
24k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
53
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Rails Girls Zürich Keynote
gr2m
96
14k
Speed Design
sergeychernyshev
33
1.5k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
30 Presentation Tips
portentint
PRO
1
220
Practical Orchestrator
shlominoach
191
11k
The World Runs on Bad Software
bkeepers
PRO
72
12k
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