react-avatar-editor icon indicating copy to clipboard operation
react-avatar-editor copied to clipboard

usage without typescript

Open x-tropy opened this issue 2 years ago • 4 comments

This might not be an issue. I got errors to let me install types

x-tropy avatar Dec 01 '23 08:12 x-tropy

Please provide the errors, so we can tell.

mosch avatar Dec 08 '23 08:12 mosch

  1. I'm using next.js, without typescript.
  2. I have installed the package correctly.
  3. Here is the example code, I directly copied into page.js
import AvatarEditor from 'react-avatar-editor';

const MyEditor = () => {
  return (
    <AvatarEditor
      image="default_avatar.png"
      width={250}
      height={250}
      border={50}
      color={[255, 255, 255, 0.6]} // RGBA
      scale={1.2}
      rotate={0}
    />
  );
};

export default MyEditor;

The error I got:

./node_modules/react-avatar-editor/src/index.ts
Module parse failed: Unexpected token (2:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import React, {
>   type TouchEventHandler,
|   type CSSProperties,
|   type MouseEventHandler,

It seems the package is not even imported. Not sure why, it'll great to get some help.

x-tropy avatar Dec 08 '23 12:12 x-tropy

May I ask: what kind of webpack loader should I use? @mosch

x-tropy avatar Dec 08 '23 12:12 x-tropy

Do you use v13.x? There might have been a mishap in the releases. It looks like NPM latest is on v14.0.0-beta5, but this is wrong (it should only be on the beta tag) I've released v13.0.1 (which is the same as 13.0.0) so 13.0.1 should show as the latest version again. Can you try it with this?

(I also marked the mistagged version as deprecated)

dan-lee avatar Dec 08 '23 12:12 dan-lee