$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
new version of context in React 16.3
Search
sota ohara
March 30, 2018
3
1.6k
new version of context in React 16.3
sota ohara
March 30, 2018
Tweet
Share
More Decks by sota ohara
See All by sota ohara
Re-Architecture of ReactNative
sottar
0
210
Implement prerendering w/ puppeteer
sottar
1
230
create own CMS from scratch
sottar
2
8.9k
Let’s try to hack AST of JavaScript
sottar
1
1.7k
フロントエンドエンジニアが伝えたい最近の事情
sottar
28
18k
複数人で高速に開発するためのnpmモジュール
sottar
5
2.5k
2ヶ月半でサービスをリリースした話し
sottar
2
2.1k
Redux のディレクトリ構成を考える
sottar
2
14k
モダンなJavaScriptアプリケーションでモダンにスタイリングする方法
sottar
9
4.9k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6.1k
Raft: Consensus for Rubyists
vanstee
136
6.7k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
How STYLIGHT went responsive
nonsquared
95
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Building an army of robots
kneath
302
44k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
110
49k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Scaling GitHub
holman
458
140k
Automating Front-end Workflow
addyosmani
1366
200k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
new version of context in React 16.3 - We Are
JavaScripters! @17th Mercari, inc. Frontend Engineer Sota Ohara
about me Sota Ohara / sottar Mercari, inc. / Souzoh,
inc. Frontend Engineer mercari NOW, CSTool @sottar_ sottar
React v16.3 is upcoming
React v16.3 is upcoming React v16.3 has released
React v16.3 has released https://twitter.com/reactjs/status/979458172833357825
• New life-cycle methods The functions that will be deprecated
are: • componentWillMount • componentWillUpdate • componentWillReceiveProps New method is: • static getDerivedStateFromProps • StrictMode API • AsyncMode • Update React DevTools • Update Context API ….. What’s new in React v16.3
New context API
• Typically, data in a React application is passed top-
down (parent to child) via props. • So, we also need to pass the related entire site values each layer components motivation it’s too painful !!
• The value set in the context can be acquired
from any child component. • New component types: Provider and Consumer. • Refer to the ancestor as the provider and the child as the consumer • Providers and consumers come in pairs New context API
Basic Sample
* A provider-consumer pair is created using * requires a
default value React.createContext() React.createContext()
* The provider accepts a context value as a prop
* In the typical scenario, context value has in state. and updated by calling setState. Provider
* The consumer uses a render prop API * In
the typical scenario, context value has in state and updated by calling setState. Consumer
FYI. What’s new in React 16.3(0-alpha) https://medium.com/@baphemot/whats-new-in-react-16-3-d2c9b7b6193b
We are hiring !!