tippyjs-react icon indicating copy to clipboard operation
tippyjs-react copied to clipboard

I would like to use a singleton in several different component contexts.

Open fwang-laralabs opened this issue 4 years ago • 2 comments

I want to use the singleton function in different components. However, it cannot be used because the SingletonObject type is not exported.

Is it possible to modify it?

-- translated by google

서로 다른 컴포넌트에서 singleton 기능을 사용 하고 싶습니다. 하지만 SingletonObject 타입이 export 되어 있지 않아 사용 할 수 없습니다.

수정이 가능합니까?

fwang-laralabs avatar Mar 25 '21 08:03 fwang-laralabs

i would also like to see/use the SingletonObject type. how else am i supposed to pass the SingletonObject around. for now, i see the type is simple enough to just make my own that matches what i found here:

https://github.com/atomiks/tippyjs-react/blob/master/index.d.ts#L37

type SingletonObject = {
  data?: any;
  hook(args: SingletonHookArgs): void;
};

omgoshjosh avatar Apr 07 '21 16:04 omgoshjosh

Since TippyProps is exported, and it contains a singleton type, you can access SingletonObject through that:

import Tippy, { TippyProps } from '@tippyjs/react'

interface Props {
  tippySingleton: TippyProps['singleton']
}

But I agree that SingletonObject should probably be exported by itself.

ksweetie avatar Apr 13 '21 22:04 ksweetie