Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
React for Gutenberg, WordPress & Beyond - WordC...
Search
Zac Gordon
October 06, 2018
Technology
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React for Gutenberg, WordPress & Beyond - WordCamp Baltimore 2018
Zac Gordon
October 06, 2018
More Decks by Zac Gordon
See All by Zac Gordon
How We Can Make WordPress Better for the JAMstack
zgordon
0
360
Decoupled Days - JAMstack and WordPress for 2020
zgordon
0
210
The State of JavaScript and WordPress in 2020
zgordon
0
1k
100 Things to Know About Building, Selling and Supporting Online Courses and Content
zgordon
0
740
Highly Dynamic WordPress Sites with Gatsby and WordPress
zgordon
0
1.1k
How the New Redux Based Data API is Changing Everything in WordPress*
zgordon
0
460
The Data API in WordPress - WCMIA 2019
zgordon
0
1.2k
Building Custom WordPress Blocks with React - WCPHX 2019
zgordon
0
110
WordCamp Seattle 2017 JavaScript Workshop
zgordon
0
1.1k
Other Decks in Technology
See All in Technology
IoTとは〜? 数字で見るSORACOM UG【SORACOM UG Explorer 2026】
soracom
PRO
0
190
Context Ontology Accelerator 入門 (業務データの意味を、AI エージェントに渡す)
inariku
PRO
1
180
続・ソフトウェアアーキテクトのための意思決定術: Decision Readiness, Revisited — When AI Changes the Economics of Software Architecture
snoozer05
PRO
9
2.5k
セキュリティ専任チームなしで攻撃を先回りするSREが実践したSIEM on Amazon OpenSearch Service
cscengineer
PRO
0
390
IBC 2026 動画技術関連レポート / IBC 2026 Report
cyberagentdevelopers
PRO
2
440
コードレビューをなくして見えたもの
henteko
0
140
新米を「売り越さない」、Aurora DSQLで作る在庫ゼロ死守の限定ドロップEC
yama3133
0
180
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
140
cdkd (CDK Direct)
gotok365
3
240
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
220
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
800
レガシーコードに対する loop engineering的なAI開発プロセス導入について
kubell_hr
0
260
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.6k
A better future with KSS
kneath
240
18k
New Earth Scene 8
popppiees
4
2.8k
Claude Code のすすめ
schroneko
67
230k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
KATA
mclloyd
PRO
35
16k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
580
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
510
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
HDC tutorial
michielstock
2
1k
Paper Plane
katiecoart
PRO
5
55k
Transcript
javascriptforwp.com/bmore @zgordon React for Gutenberg, WordPress & Beyond w Zac
Gordon
javascriptforwp.com/bmore @zgordon Hi! I’m Zac zacgordon.com
javascriptforwp.com/bmore @zgordon How & Why React is Included w WordPress
javascriptforwp.com/bmore @zgordon A bit of history..
javascriptforwp.com/bmore @zgordon Gutenberg is React Under the Hood
javascriptforwp.com/bmore @zgordon Built Decoupled Wired to WordPress
@zgordon javascriptforwp.com/bmore gutenberg-standalone.surge.sh
@zgordon javascriptforwp.com/bmore drupalgutenberg.org
javascriptforwp.com/bmore @zgordon Gutenberg Editor is a Modern React App
@zgordon javascriptforwp.com/bmore npmjs.com/~WordPress
@zgordon javascriptforwp.com/bmore
javascriptforwp.com/bmore @zgordon Better Standards for WordPress JavaScript
@zgordon javascriptforwp.com/bmore github.com/WordPress-Coding-Standards/eslint-plugin-wordpress
javascriptforwp.com/bmore @zgordon Gutenberg Editor is a Modern React App
javascriptforwp.com/bmore @zgordon React in WordPress
javascriptforwp.com/bmore @zgordon The Great WordPress React Abstraction
@zgordon // Enqueue JS - React Dependency? wp_enqueue_script( 'myplugin-js', plugins_url(
null, __FILE__ ) . '/js/plugin.js', [ 'jquery' ] );
@zgordon // Enqueue JS - React Dependency? wp_enqueue_script( 'myplugin-js', plugins_url(
null, __FILE__ ) . '/js/plugin.js', [ 'react' ] );
@zgordon javascriptforwp.com/bmore In WordPress React == wp.element
@zgordon javascriptforwp.com/bmore github.com/WordPress/gutenberg/tree/master/packages/element
@zgordon javascriptforwp.com/bmore The Great WordPress React Abstraction
@zgordon // Normal React const el = React.createElement('h1', null, 'Welcome!');
// WordPress React const el = wp.element.createElement('h1', null, 'Welcome!');
@zgordon // Normal ReactDOM ReactDOM.render( el, document.getElementById( 'root' ) );
// WordPress ReactDOM wp.element.render( el, document.getElementById( ‘root' ) );
@zgordon javascriptforwp.com/bmore wp.element is Available in the DOM window object*
window.wp.element
@zgordon javascriptforwp.com/bmore gutenberg.local
@zgordon // WordPress React - Normal const el = wp.element.createElement('h1',
null, 'Welcome!'); // WordPress React - Destructured const { createElement } = wp.element; const el = createElement('h1', null, 'Welcome!');
javascriptforwp.com/bmore @zgordon To Use React Outside of Gutenberg
@zgordon // Enqueue JS - React Dependency? wp_enqueue_script( 'myplugin-js', plugins_url(
null, __FILE__ ) . '/js/plugin.js', [ 'wp-element' ] );
@zgordon javascriptforwp.com/bmore gutenberg.local
javascriptforwp.com/bmore @zgordon We Also Have JSX In WordPress
@zgordon <PanelBody> <TextControl label={ __( 'Text Field', 'domain' ) }
value={ textControl } onChange={ textControl =>" setAttributes( { textControl } ) } /> </PanelBody> <PanelBody> <TextareaControl label={ __( 'Text Area Field', 'domain' ) } value={ textareaControl } onChange={ textareaControl =>" setAttributes( { textareaControl } ) } /> </PanelBody>
@zgordon javascriptforwp.com/bmore You will need Babel to use JSX..
@zgordon javascriptforwp.com/bmore npmjs.com/package/@wordpress/babel-preset-default
@zgordon javascriptforwp.com/bmore npmjs.com/package/@wordpress/babel-plugin-import-jsx-pragma
@zgordon <PanelBody> <TextControl label={ __( 'Text Field', 'domain' ) }
value={ textControl } onChange={ textControl =>" setAttributes( { textControl } ) } /> <TextareaControl label={ __( 'Text Area Field', 'domain' ) } value={ textareaControl } onChange={ textareaControl =>" setAttributes( { textareaControl } ) } /> </PanelBody>
javascriptforwp.com/bmore @zgordon A React Component Library For WordPress!
@zgordon javascriptforwp.com/bmore wp.components
@zgordon const { Autocomplete, Button, CheckboxControl, ColorPalette, DropZone, FormToggle, Panel,
Popover, Spinner, TextControl, TextareaControl, Tooltip, } = wp.components; const CustomTooltip = () =>" ( <Tooltip text="More Info"> <Button isDefault> Hover for Tooltip </Button> </Tooltip> );
javascriptforwp.com/bmore @zgordon Redux in WordPress
@zgordon javascriptforwp.com/bmore github.com/WordPress/gutenberg/tree/master/packages/data#comparison-with-redux
@zgordon javascriptforwp.com/bmore Ability to Create Our Own Data Stores Using
WP Redux
@zgordon javascriptforwp.com/bmore github.com/WordPress/gutenberg/tree/master/packages/core-data
@zgordon javascriptforwp.com/bmore Use Data API Instead Of Your Own WP
REST API Calls *
@zgordon const { withSelect, withDispatch, } = wp.data;
@zgordon const { withSelect } = wp.data; function MyAuthorsListBase( {
authors } ) { return ( <ul> { authors.map( ( author ) =>" ( <li key={ author.id }>{ author.name }</li> ) ) } </ul> ); } const MyAuthorsList = withSelect( ( select ) =>" ( { authors: select( 'core' ).getAuthors(), } ) )( MyAuthorsListBase );
@zgordon const { withSelect } = wp.data; function MyPostsListBase( {
posts } ) { return ( <ul> { posts.map( ( post ) =>" ( <li key={ post.id }>{ post.title.rendered }</li> ) ) } </ul> ); } const MyPostList = withSelect( ( select ) =>" ( { posts: select( 'core' ).getEntityRecords( 'postType', 'post', { per_page: 5 } ) } ) )( MyPostsListBase );
@zgordon edit: withSelect( select =>" { return { posts: select(
'core' ).getEntityRecords( 'postType', 'post', { per_page: 5 } ) }; } )( ( { posts } ) =>" { return ( <ul> { posts.map( post =>" { return <li>{ post.title.rendered }</li>; }) } </ul> ); } )
@zgordon javascriptforwp.com/bmore npmjs.com/package/@wordpress/api-fetch
javascriptforwp.com/bmore @zgordon React in WP Immediate Future vs. Next Few
Years
javascriptforwp.com/bmore @zgordon Gutenberg “Block” Editor
javascriptforwp.com/bmore @zgordon Gutenberg “Block” Editor, Widgets, Customizer, Themes, Plugins, Decoupled
javascriptforwp.com/bmore @zgordon Do I Need to Learn All of This?
javascriptforwp.com/bmore @zgordon 20% OFF Gutenberg Course javascriptforwp.com/bmore Q&A