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 for Gutenberg, WordPress & Beyond - WordC...
Search
Zac Gordon
October 06, 2018
Technology
270
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
350
Decoupled Days - JAMstack and WordPress for 2020
zgordon
0
200
The State of JavaScript and WordPress in 2020
zgordon
0
970
100 Things to Know About Building, Selling and Supporting Online Courses and Content
zgordon
0
710
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
430
The Data API in WordPress - WCMIA 2019
zgordon
0
1.1k
Building Custom WordPress Blocks with React - WCPHX 2019
zgordon
0
97
WordCamp Seattle 2017 JavaScript Workshop
zgordon
0
1.1k
Other Decks in Technology
See All in Technology
TypeScript入門 2026
recruitengineers
PRO
3
530
サイバー捜査員研修(後半)
nomizone
1
830
FPGAが実現する遠方宇宙の高空間分解能天体撮影 -大型地上望遠鏡の視力を補正する「補償光学」とは?-
komei_mt
0
210
Goでデータパイプラインを作ろう
sansantech
PRO
1
370
AI時代の強いチームの作り方
yuukiyo
26
16k
AIは実装を速くする。では、私たちは何を今作るべきか?-立場を越えてリリースに向き合ったチーム開発の実践 / 20260801 Hiromi Nakaya and Naoki Takahashi
shift_evolve
PRO
3
460
20分でわかるセキュアAPI
nwiizo
2
230
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
170
システム思考で問題に対処する
yussak
0
220
Pavlokで始める電撃駆動開発
sgrsn
0
180
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.7k
AWS ネットワーク構築でハマった(ハマりかけた) 5選とそこから得た教訓
nagisa53
4
200
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.8k
The Pragmatic Product Professional
lauravandoore
37
7.4k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
240
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
290
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
Code Review Best Practice
trishagee
74
20k
How to Talk to Developers About Accessibility
jct
2
500
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
590
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Facilitating Awesome Meetings
lara
57
7.1k
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