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
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
120
ぼくの開発環境2026
yuzneri
0
230
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
Basic Architectures
denyspoltorak
0
680
組織で育むオブザーバビリティ
ryota_hnk
0
180
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
310
Implementation Patterns
denyspoltorak
0
290
Architectural Extensions
denyspoltorak
0
290
CSC307 Lecture 08
javiergs
PRO
0
670
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
980
Featured
See All Featured
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
How to Talk to Developers About Accessibility
jct
2
130
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
67
Accessibility Awareness
sabderemane
0
52
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
62
Claude Code のすすめ
schroneko
67
210k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
83
Technical Leadership for Architectural Decision Making
baasie
1
240
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