Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = Fill;
|
|
var _element = require("@wordpress/element");
|
|
var _context = _interopRequireDefault(require("./context"));
|
|
var _useSlot = _interopRequireDefault(require("./use-slot"));
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
|
|
function Fill({
|
|
name,
|
|
children
|
|
}) {
|
|
const {
|
|
registerFill,
|
|
unregisterFill
|
|
} = (0, _element.useContext)(_context.default);
|
|
const slot = (0, _useSlot.default)(name);
|
|
const ref = (0, _element.useRef)({
|
|
name,
|
|
children
|
|
});
|
|
(0, _element.useLayoutEffect)(() => {
|
|
const refValue = ref.current;
|
|
registerFill(name, refValue);
|
|
return () => unregisterFill(name, refValue);
|
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
(0, _element.useLayoutEffect)(() => {
|
|
ref.current.children = children;
|
|
if (slot) {
|
|
slot.forceUpdate();
|
|
}
|
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [children]);
|
|
(0, _element.useLayoutEffect)(() => {
|
|
if (name === ref.current.name) {
|
|
// Ignore initial effect.
|
|
return;
|
|
}
|
|
unregisterFill(ref.current.name, ref.current);
|
|
ref.current.name = name;
|
|
registerFill(name, ref.current);
|
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [name]);
|
|
return null;
|
|
}
|
|
//# sourceMappingURL=fill.js.map
|