Skip to content
Discussion options

You must be logged in to vote

Use useRef to make it injected once😆

const isServerInserted = useRef(false);

useServerInsertedHTML(() => {
  if (!isServerInserted.current) {
    isServerInserted.current = true;
    const styles = styledComponentsStyleSheet.getStyleElement();
    styledComponentsStyleSheet.instance.clearTag();
    return <>{styles}</>;
  }
});

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@dejurin
Comment options

@gregoire-jianda
Comment options

Answer selected by dejurin
Comment options

You must be logged in to vote
1 reply
@itsmelion
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants