If you are not developing, please suggest in reverse. The
For example, to install the WordPress element module in the WordPress plug-in, please: or install it outside the WordPress environment, and then: import the correlation into the webpack for use in the scope. It is the same as the last few examples. That’s the point. This line of code runs in the context of Gutenberg blocks, other WP admin screens, applications deployed outside the WordPress environment, and all further careful testing. WP global management word press uses global state. This can complicate the situation, but Gutenberg’s use of WP global variables is the easiest global state for WordPress developers to manage. Let’s take a look at some of the problems I have encountered due to the unpredictability of the global state and the ways to solve them. The
For non Gutenberg WP admin screens, using the WordPress Babel preset in the WordPress plug-in means a lot to me. Keep the Babel configuration very simple. The{
\
}One thing it does is compile JSX using elements in word press. Global variable WP. As long as the element is set, it is fine. On the Gutenberg screen. If the component is imported into realct, problems may occur. The
This problem occurs when using the realt component on the WP admin screen that shares my Gutenberg blocks and components@ When wordpress\/element is not in NPM, the solution is to do what Gutenberg does. Wp React element. Please define the same as element. This is not a scalable solution, but it works. As mentioned earlier, repackage the code to use @wordpress\/element. However, this is a problem for anyone who maintains both react and WordPress code. The
One of the biggest reasons to use react during testing is jest. I love jester. Jest is the simplest test tool I have ever used. This is not a tutorial for jest, but I want to introduce the test setup of components shared between Gutenberg and other realt applications. Because caldera forms uses jest, WP. You must ensure that the element has been defined. Shim copied by Gutenberg is currently being used to prevent errors in the test. Here: battle. WP ={
Short code:{
},
API request:{
}The
};
Object Defineproperty (global.wp, \
Import: () = > requirement (\
}); Don’t you look familiar? It’s the same as a word press. In fact, modules in NPM have recently been released to provide simple, repeatable solutions@ Please pay attention to the content published to NPM within WordPress organization. The
Male jest must be informed to use the corresponding configuration file. Here is the package The complete jest settings to add to JSON. React and wordpresena wrote a lot about choice in react and vuejs. Gutenberg previously worked on the vuejs team. However, while learning Gutenberg’s development, you need to have an in-depth understanding of realt and re evaluate JSX’s initial negative comments, that is, the template language commonly used for realt components. In order to develop Gutenberg, you don’t need to know realt, but it is really helpful. In addition, realct is not required. Using Gutenberg to use Vue in the block UI to provide status for Vue components
I did. This is an unnecessary layer of complexity. Although it is actually cool, it needs to keep Vue and realt in the web package and consider many reasonable reasons for the two frameworks. The
The states of Vue and realt management are very different, so they retain their rules, and the other syntax of the template language will not be expanded in spirit. I like Vue very much because I use Redux (-like) state management of WordPress data, but when WordPress made me rethink JSX and know how to use it really well in WordPress plug-ins, I was sold in react. One of Vue’s problems is state management. As the recommended state management solution, vuex needs too many common tools, and it is difficult to integrate with components if it cannot effectively generate global state. Maybe I was wrong, but vuex didn’t click on me. At present, Redux is the standard for the state management of react applications, which is more reasonable than vuex. This is the second reason why I switched to realt. WordPress now uses abstraction on Gutenberg’s react, so it is not practical to use Vue and react at the same time. The more you integrate with Gutenberg, the more you use realt. This is the simplest solution. We also like to use containers with react+redux and demonstrate how component patterns can isolate problems and simplify unit tests. Gutenberg’s Redux abstraction can be used as @wordpress\/data in NPM to make Redux simpler@ When registering a \