Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
2.2. Static Block Replacement
const trackerClass = '.wp-block-rave-initiative-tracker',
trackers = document.querySelectorAll( trackerClass );
trackers.forEach( ( tracker ) => {
const attributes = {
block_id: tracker.dataset.id,
post_id: parseInt( tracker.dataset.post_id, 10 ),
};
render(
<FrontendTracker dataAttributes={ attributes } />,
tracker
);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment