Skip to content

Type error with React 18 and TypeScript #258

@Egor-Koldasov

Description

@Egor-Koldasov

Sample code

import ReactAvatar, { ConfigProvider } from "react-avatar";

const allowedColors: string[] = ["#ffffff", "#000000"];
export default function App() {
  return (
    <div className="App">
      <ConfigProvider colors={allowedColors}>
        <ReactAvatar name="Egor Koldasov" />
      </ConfigProvider>
    </div>
  );

ConfigProvider throws an error

Type '{ children: Element; colors: string[]; }' is not assignable to type 'IntrinsicAttributes & ConfigProvider'.
  Property 'children' does not exist on type 'IntrinsicAttributes & ConfigProvider'.

Sandbox example

https://codesandbox.io/s/heuristic-wing-jt95g8?file=/src/App.tsx

Example versions

"dependencies": {
    "react": "18.2.0",
    "react-avatar": "5.0.3",
    "react-dom": "18.2.0",
  },
  "devDependencies": {
    "@types/react": "18.0.25",
    "@types/react-dom": "18.0.9",
    "typescript": "4.4.2"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions