Created
February 8, 2021 18:23
-
-
Save chaance/5472c5adf293063ebeddb7b421e0c271 to your computer and use it in GitHub Desktop.
React <nobr> replacement
This file contains 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
const Nobr = React.forwardRef((props, ref) => ( | |
<span ref={ref} {...props} style={{ whiteSpace: 'nowrap', ...props.style }} /> | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Typescript variant
const NoBR = React.forwardRef<HTMLSpanElement, HTMLAttributes>((props, ref) => (
<span ref={ref} {...props} style={{ ...(props.style as CSSProperties), whiteSpace: 'nowrap' }} />
));