Created
April 11, 2021 18:13
-
-
Save mtxr/bc2e347801ff0967c4c8330255b7a550 to your computer and use it in GitHub Desktop.
react patch createElement to show texts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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