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
try Undux but...
Search
tt
September 19, 2018
Programming
0
270
try Undux but...
I tryed Undux of state management but Redux is better that.
tt
September 19, 2018
Tweet
Share
More Decks by tt
See All by tt
戦略的なフロントエンドテストを実施するために
tatsushitoji
0
80
そろそろGraphQLの話をしよう
tatsushitoji
1
270
Our favorite Dependency updates has been deprived
tatsushitoji
2
460
Other Decks in Programming
See All in Programming
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.9k
童醫院敏捷轉型的實踐經驗
cclai999
0
160
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
230
Using AI Tools Around Software Development
inouehi
0
1.3k
関数型まつりレポート for JuliaTokai #22
antimon2
0
140
A2A プロトコルを試してみる
azukiazusa1
2
1k
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
300
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
300
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
110
GoのGenericsによるslice操作との付き合い方
syumai
3
680
Claude Codeの使い方
ttnyt8701
1
130
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
840
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Facilitating Awesome Meetings
lara
54
6.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
GitHub's CSS Performance
jonrohan
1031
460k
The Pragmatic Product Professional
lauravandoore
35
6.7k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
For a Future-Friendly Web
brad_frost
179
9.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Producing Creativity
orderedlist
PRO
346
40k
Transcript
ReduxʹർΕͨͷͰ UnduxΛૉৼΓͯ͠Έͨ Osaka Mix Leap Study #23 React Nativeษڧձ @tatsushitoji
Who am I ? • @tatsushitoji • σβΠϯࣄॴɺήʔϜձࣾɺweb੍࡞ձ ࣾɺۙͰιʔγϟϧϩάΠϯͳͲΛఏڙ ͢ΔࣄۀձࣾΛܦͯɺݱࡏɺwebࣄۀҎ֎
ͷۀछΛபͱͨ͠ձࣾͰwebࣄۀͷ্ཱͪ͛ Λߦ͍ͬͯ·͢
Dead simple state management for React
storeΛ࡞ import { createConnectedStore } from 'undux' import { initialCounterState
} from './modules/counter' export const store = createConnectedStore({ ...initialCounterState, }) import { createStore, combineReducers } from 'redux' import { counterReducer } from ‘./modules/counter' export const store = createStore( combineReducers({ counter: counterReducer, }), ) 6OEVY 3FEVY
ContainerͰϥοϓ͢Δ import Store from './store' import { Counter } from
'./components/counter' import registerServiceWorker from './registerServiceWorker' ReactDOM.render( <Store.Container> <Counter /> </Store.Container>, document.getElementById('root') import { store } from './store' import { Container as Counter } from './containers/counter' ReactDOM.render( <Provider store={store}> <Counter /> </Provider>, document.getElementById('root') ) 6OEVY 3FEVY
connect͢Δ import * as React from 'react' import { withStore
} from '../../store' export const Counter = withStore(({ store }) => ( <> … </> )) import { connect } from 'react-redux' import { Counter } from '../../components/counter' export const Container = connect(state => state)(Counter) 6OEVY 3FEVY
Dead Simple ! import * as React from 'react' import
{ withStore } from '../../store' export const Counter = withStore(({ store }) => ( <div> <p>count: {store.get('countValue')}</p> <button onClick={() => store.set('countValue')(store.get('countValue') + 1)}>Increment</button> <button onClick={() => store.set('countValue')(store.get('countValue') - 1)}>Decrement</button> <button onClick={() => store.set('countValue')(0)}>Reset</button> </div> ))
͔ͨ͠ʹγϯϓϧ͕ͩεέʔϧ ͢Δ…ʁ • storeΛ·Δ͝ͱίϯϙʔωϯτʹͭͬ͜Ήͱ ͍͏உؾ͋;ΕΔେͳઃܭ • view ଆ(presentational Component)ʹ͕ ৭ʑͱͬͯ͘Δ
ͬͯΈͨ • storeUpdaterͷ • Store Λඞཁͳ͚ͩϚοϐϯά
ຐվ… export const Counter = compose( withStore, withHandlers({ onIncrement: ({
store }) => () => store.set('countValue')(store.get('countValue') + 1), onDecrement: ({ store }) => () => store.set('countValue')(store.get('countValue') - 1), onReset: ({ store }) => () => store.set('countValue')(0), }), mapProps(({ store, onIncrement, onReset, onDecrement }) => ({ onIncrement, onDecrement, onReset, countValue: store.get('countValue'), })), )(Component)
• mapProps Ͱ react-redux ͷ mapStateToProps ʹ͍ۙ͜ͱΛ͍ͬͯΔ • WithHandlers Ͱ
react-redux ͷ mapDispatchToProps ʹ͍ۙ͜ͱΛ͍ͬͯΔ • ܕͭΒ͍ • Redux ͍͍͑ͷͰ…ʁ
ReduxʹർΕͨͷͰ UnduxΛૉৼΓͯ͠Έͨ…
݁Ռɺ ෳਓ։ൃɺ·ͨ͋ΔఔنҎ্ ͕ఆ͞ΕΔΞϓϦέʔγϣϯͷঢ়ଶ ཧʹ͓͍ͯ Redux ͷ store ͷ mutaion ͷઃܭͱ
react-redux ͷ connect ڞ௨ೝࣝͱ͍ͯ࣋ͪ͢͠ ͠ɺducks ͳσΟϨΫτϦߏʹ͢Ε ϑΝΠϧҠಈͷΦʔόʔϔου͑ ΒΕΔ͠… ͦͦɺReduxʹർΕͯͳͲ͍ͳ͍
ϦϙδτϦ • https://github.com/tatsushitoji/cra-redux • https://github.com/tatsushitoji/cra-undux ※ feat/optimize-connect ϒϥϯνͰ͋Δఔ·Ͱͷ࠷దԽΛ͍ͬͯ·͢
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠