Skip to content

Instantly share code, notes, and snippets.

@mtxr
Created April 11, 2021 18:13
Show Gist options
  • Save mtxr/bc2e347801ff0967c4c8330255b7a550 to your computer and use it in GitHub Desktop.
Save mtxr/bc2e347801ff0967c4c8330255b7a550 to your computer and use it in GitHub Desktop.
react patch createElement to show texts
import React from 'react';
const createElement = React.createElement;
(React as any).createElement = (...args: any[]) => {
const el = (createElement as any)(...args);
if (
typeof el.props.children === "string" &&
el._source &&
el.props.children
) {
console.log("FOUND TEXT", { text: el.props.children, source: el._source });
}
return el;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment