Created
April 11, 2019 00:16
-
-
Save wjramos/1a3536473a553c640ea43aa8df1d3908 to your computer and use it in GitHub Desktop.
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
export function extractNodeText(node) { | |
if (typeof node === 'string') return node; | |
if (React.isValidElement(node)) { | |
const { messageKey, messagesMap } = node.props; | |
if (messageKey && messagesMap) { | |
return messagesMap[messageKey]; | |
} | |
return node.innerText; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment