[wp-trac] [WordPress Trac] #45271: Can't enqueue WordPress 5.0 builtin reactjs

WordPress Trac noreply at wordpress.org
Sun Nov 4 01:01:36 UTC 2018


#45271: Can't enqueue WordPress 5.0 builtin reactjs
-------------------------------+-------------------------
 Reporter:  CantoThemes        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  5.0
Component:  General            |     Version:  5.0
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  javascript
-------------------------------+-------------------------
Changes (by pento):

 * keywords:   => reporter-feedback
 * milestone:  Awaiting Review => 5.0


Comment:

 Thank you for the bug report, @CantoThemes!

 Which action are you hooking `load_assets` into? I was able to enqueue
 `react` and `react-dom` by hooking into the `init` action.

 It's worth noting that loading WordPress' `react` is possible, but may
 cause compatibility issues in the future: we'll be aiming to keep React
 fairly up to date, and as React does drop support for older APIs over
 time, you'll need to ensure your code is also up to date.

 There are a couple of options here:

 - if you need to work directly with React (for example, the code you're
 writing also operates entirely outside of WordPress), I'd recommend
 bundling your supported version of React with your plugin, loading the
 WordPress version if you support it, or your version if you need to.
 - If this code is intended to run in WordPress, I'd recommend looking at
 using the [https://wordpress.org/gutenberg/handbook/packages/packages-
 element/ WordPress Element], instead. Element is currently a thin
 abstraction layer around React, it exposes the APIs in React that we're
 confident will either be part of React for the foreseeable future, or that
 we can provide a compatibility layer for if needed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45271#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list