/**
* External dependencies
*/
import { useMemo, useContext } from 'preact/hooks';
import { deepSignal } from 'deepsignal';
/**
* Internal dependencies
*/
import { component } from './hooks';
export default () => {
const WpContext = ( { children, data, context: { Provider } } ) => {
const signals = useMemo(
() => deepSignal( JSON.parse( data ) ),
[ data ]
);
return { children };
};
component( 'wp-context', WpContext );
const WpShow = ( { children, when, evaluate, context } ) => {
const contextValue = useContext( context );
if ( evaluate( when, { context: contextValue } ) ) {
return children;
}
return { children };
};
component( 'wp-show', WpShow );
};