Skip to content

Thema/Type is not applied at first render, default dark is set even if the type prop is light #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
whiteadi opened this issue Nov 11, 2021 · 3 comments · Fixed by #735

Comments

@whiteadi
Copy link

whiteadi commented Nov 11, 2021

I have the tooltip as this:

<ReactTooltip id="downloadTooltip" place="top" title={downloadTooltipTitle} type="light">
...
</ReactTooltip>

and first render has it with dark type and it is also not working, if i do some other action and get back to it it has the hardcoded light theme/type and working.

@bonesoul
Copy link

same issue here.

@whiteadi
Copy link
Author

whiteadi commented Jan 17, 2022

the way I fixed it, having it inside a modal:

import React, { Fragment, useMemo, memo, useEffect } from 'react';
import ReactTooltip from 'react-tooltip';
import clsx from 'clsx';
import { nanoid } from 'nanoid';

....


const Tooltip = (props: TooltipProps) => {
  const {
    children,
    className,
    id = nanoid(),
    title,
    place = 'top',
    delayShow = 400,
    disable = false,
    withShadow,
    type = 'dark',
    fontSize,
    disableRebuild = false,
    ...restProps
  } = props;

  const childrenProps = useMemo(
    () => ({
      ...children.props,
      'data-tip': title,
      'data-for': id,
    }),
    [children.props, title, id],
  );

  // Recalculate Tooltip position in modals https://github.com/wwayne/react-tooltip/issues/130
  useEffect(() => {
    if (!disableRebuild) {
      requestAnimationFrame(() => {
        ReactTooltip.rebuild();
      });
    }
  }, [disableRebuild]);

  return (
    <Fragment>
      {React.cloneElement(children, childrenProps)}

      <ReactTooltip
        id={id}
        className={clsx(
          styles.self,
          withShadow && styles.withShadow,
          type === 'light' && styles.fullOpacity,
          fontSize && styles[`fontSize-${fontSize}`],
          className,
        )}
        effect="solid"
        place={place}
        delayShow={delayShow}
        disable={disable}
        type={type}
        {...restProps}
      />
    </Fragment>
  );
};

@bonesoul
Copy link

i replaced it with https://www.npmjs.com/package/@tippyjs/react which is perfectly happy with SSR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants