Skip to content

Instantly share code, notes, and snippets.

@chaance
Created February 8, 2021 18:23
Show Gist options
  • Save chaance/5472c5adf293063ebeddb7b421e0c271 to your computer and use it in GitHub Desktop.
Save chaance/5472c5adf293063ebeddb7b421e0c271 to your computer and use it in GitHub Desktop.
React <nobr> replacement
const Nobr = React.forwardRef((props, ref) => (
<span ref={ref} {...props} style={{ whiteSpace: 'nowrap', ...props.style }} />
));
Copy link

ghost commented Nov 15, 2022

// Typescript variant
const NoBR = React.forwardRef<HTMLSpanElement, HTMLAttributes>((props, ref) => (
<span ref={ref} {...props} style={{ ...(props.style as CSSProperties), whiteSpace: 'nowrap' }} />
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment