Skip to content
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

Type error with React 18 and TypeScript #258

Open
Egor-Koldasov opened this issue Mar 13, 2023 · 6 comments
Open

Type error with React 18 and TypeScript #258

Egor-Koldasov opened this issue Mar 13, 2023 · 6 comments

Comments

@Egor-Koldasov
Copy link

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"
  },
@hhoangg
Copy link

hhoangg commented Mar 27, 2023

I have the same problem

@atefBB
Copy link

atefBB commented May 23, 2023

@Egor-Koldasov did u manage to solve this issue ? any help will be appreciated !

@okradze
Copy link

okradze commented Oct 10, 2023

I have same issue

@renebigot
Copy link

Same issue here

@renebigot
Copy link

For future readers : You can fix this lint error with a comment.

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    { /* @ts-expect-error : ConfigProvider has no children property in interface declaration */}
    <ConfigProvider colors={AVATAR_COLORS}>
      <App />
    </ConfigProvider>
  </React.StrictMode>
)

@TannerJuby1
Copy link

@renebigot that is not a "fix", that is a workaround.

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

No branches or pull requests

6 participants