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>
64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
import { createElement, Fragment } from "react";
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { Component } from '@wordpress/element';
|
|
class Dropdown extends Component {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.toggle = this.toggle.bind(this);
|
|
this.close = this.close.bind(this);
|
|
this.state = {
|
|
isOpen: false
|
|
};
|
|
}
|
|
componentWillUnmount() {
|
|
const {
|
|
isOpen
|
|
} = this.state;
|
|
const {
|
|
onToggle
|
|
} = this.props;
|
|
if (isOpen && onToggle) {
|
|
onToggle(false);
|
|
}
|
|
}
|
|
componentDidUpdate(prevProps, prevState) {
|
|
const {
|
|
isOpen
|
|
} = this.state;
|
|
const {
|
|
onToggle
|
|
} = this.props;
|
|
if (prevState.isOpen !== isOpen && onToggle) {
|
|
onToggle(isOpen);
|
|
}
|
|
}
|
|
toggle() {
|
|
this.setState(state => ({
|
|
isOpen: !state.isOpen
|
|
}));
|
|
}
|
|
close() {
|
|
this.setState({
|
|
isOpen: false
|
|
});
|
|
}
|
|
render() {
|
|
const {
|
|
isOpen
|
|
} = this.state;
|
|
const {
|
|
renderContent,
|
|
renderToggle
|
|
} = this.props;
|
|
const args = {
|
|
isOpen,
|
|
onToggle: this.toggle,
|
|
onClose: this.close
|
|
};
|
|
return createElement(Fragment, null, renderToggle(args), isOpen && renderContent(args));
|
|
}
|
|
}
|
|
export default Dropdown;
|
|
//# sourceMappingURL=index.native.js.map
|