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

We need react 17 support

Open realJustinLee opened this issue 3 years ago • 2 comments

realJustinLee avatar Apr 19 '21 15:04 realJustinLee

Agreed. Any chance this can get traction?

DakotaLarson avatar May 02 '21 03:05 DakotaLarson

Can easily be solved by implementing this wrapper on your own - it's ~30 lines.

import { useEffect, useRef, VoidFunctionComponent } from "react";
import { default as TypedLib } from "typed.js";

const Typed: VoidFunctionComponent<{ options: any }> = ({options}) => {
  const ref = useRef<HTMLSpanElement | null>(null);

  useEffect(() => {
    if (! ref.current) {
      return;
    }
    const typed = new TypedLib(ref.current, options);

    return () => {
      if (!typed) {
        return;
      }
      typed.destroy();
    };
  }, [ref, options]);

  return (
    <div>
      <span ref={ref} />
    </div>
  );
};

export default Typed;

any sucks, I know, but unfortunately TypedOptions are not exported (see https://github.com/mattboldt/typed.js/pull/494)

nehalist avatar Dec 01 '21 18:12 nehalist

Perhaps update the README with https://github.com/ssbeefeater/react-typed/issues/26#issuecomment-983953018 and mark this package as deprecated?

I implemented the wrapper and ditched the package. Problem solved.

robwhite4 avatar Dec 31 '22 21:12 robwhite4