@wordpress/edit-post
Version:
Edit Post module for WordPress.
24 lines (21 loc) • 608 B
JavaScript
/**
* WordPress dependencies
*/
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
/**
* Internal dependencies
*/
import BaseOption from './base';
import { store as editPostStore } from '../../../store';
export default compose(
withSelect( ( select, { featureName } ) => {
const { isFeatureActive } = select( editPostStore );
return {
isChecked: isFeatureActive( featureName ),
};
} ),
withDispatch( ( dispatch, { featureName } ) => ( {
onChange: () => dispatch( editPostStore ).toggleFeature( featureName ),
} ) )
)( BaseOption );