Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
forceClientHydration() {
const registeredComponentName = 'HelloWorldRehydratable';
const { railsContext } = this.props;
// Target all instances of the component in the DOM
const match = document.querySelectorAll(`[id^=${registeredComponentName}-react-component-]`);
// Not all browsers support forEach on NodeList so we go with a classic for-loop
for (let i = 0; i < match.length; i += 1) {
const component = match[i];
// Get component specification