ES6 /ESNext Uncaught SyntaxError: Unexpected token <
-
I have already searched for hours, but can not find the error. the react.js files are integrated by Wrdpress, my block.js follows afterwards. I can not find a solution
<?php defined('ABSPATH') || exit; class Plugin_XY_Gutenberg { public static function initGutenberg() { add_filter('block_categories', array(Plugin_XY_Gutenberg, 'xy_block_category'), 10, 2); add_action('admin_init', array(Plugin_XY_Gutenberg, 'xy_gutenberg_block'), 10, 3); } public function xy_block_category($categories, $post) { return array_merge( $categories, array( array( 'slug' => 'xy-block', 'title' => __('xy', 'xy-block'), //'icon' => 'wordpress', ), ) ); } public function xy_gutenberg_block() { $dependencies = array( 'wp-blocks', // Provides useful functions and components for extending the editor 'wp-i18n', // Provides localization functions 'wp-element', // Provides React.Component 'wp-components', // Provides many prebuilt components and controls ); wp_register_script( 'xy', plugins_url('plugin_wp_xy' . DIRECTORY_SEPARATOR . 'js/gutenberg' . DIRECTORY_SEPARATOR . 'block.js'), $dependencies ); register_block_type('xy/shortcodes', array( 'editor_script' => 'xy', )); } }
const { registerBlockType } = wp.blocks; const { Fragment } = wp.element; const { RichText, BlockControls, AlignmentToolbar } = wp.editor; registerBlockType( 'xy/shortcodes', { title :__('Example Block', 'example'), icon : 'screenoptions', category : 'xy-block', attributes : { content: { // Parsed from HTML selector source: 'children', selector: 'p', type: 'array' }, textColor: { // Serialized by default type: 'string' } }, edit(props){ const { attributes, setAttributes, className } = props; const { content } = attributes return ( <div className={className}> <RichText className="example-content" value={content} onChange={(content) =>setAttributes({ content })} /> </div> ) }, save(props){ const { attributes } = props; const { content } = attributes return ( <div> <p>{content}</p> </div> ) } });
Error here:
<div className={className}>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘ES6 /ESNext Uncaught SyntaxError: Unexpected token <’ is closed to new replies.