60 likes | 71 Views
The Technology Behind WordPress Blocks. wp-community-uk.slack.com: chrisodell. Twitter: chris@foxdellfolio.com. website: http://www.foxdellcodesmiths.com/. Email: chris.odell@foxdellcodesmiths.com. What I’m going to cover. What technology do I need to know?
E N D
The Technology Behind WordPress Blocks wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com
What I’m going to cover. • What technology do I need to know? • The rise of the JavaScript Frameworks. • What is React and should I care? • JSX? Do we need another TLA? wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com
What technology do I need to know? • Usual suspects HTML, CSS, JavaScript and PHP. • Node.js(npm), Gulp/WebPack/A.N.other. • React + JSX. wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com
The rise of the JavaScript Frameworks. var newName = 'John Smith’, xhr = new XMLHttpRequest(); xhr.open('POST', 'myservice/username?id=some-unique-id'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { if (xhr.status === 200 && xhr.responseText !== newName) { alert('Something went wrong. Name is now ' + xhr.responseText); } else if (xhr.status !== 200) { alert('Request failed. Returned status of ' + xhr.status); } else { doSomething(); } }; xhr.send(encodeURI('name=' + newName)); • Why not use pure JS • JQuery/Prototype • Vue/React/Angular $.post('myservice/username?id=some-unique-id', { newName : 'john Smith' }, function(data) { doSomething(); }); wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com
What is React and should I care? • JS Framework. • Used by all blocks in the new Block Editor. • Originally developed by Facebook. • Outside of WP often used with Flux architecture. • Allows the building of components. wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com
JSX? Do we need another TLA? • JSX is syntactic sugar. return ( <h1>Greetings, {this.props.name}!</h1> ); • Is compiled. • Not strictly required. return React.createElement('h1', null, 'Greetings, ' + this.props.name + '!'); wp-community-uk.slack.com: chrisodell Twitter: chris@foxdellfolio.com website: http://www.foxdellcodesmiths.com/ Email: chris.odell@foxdellcodesmiths.com