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

Error building (storybook) with v1.5.0 due to useId #56

Open
espada-edalex opened this issue Aug 22, 2024 · 1 comment
Open

Error building (storybook) with v1.5.0 due to useId #56

espada-edalex opened this issue Aug 22, 2024 · 1 comment

Comments

@espada-edalex
Copy link

RenovateBot opened an MR to bump the version of react-file-icon but the build is failing due to React.useId. We're using Typescript and it looks like it's complaining because that doesn't exist in out version of React (we're on 17.0.2).

ERR! [tsl] ERROR in react-frontend/node_modules/react-file-icon/dist/react-file-icon.esm.js(144,19)
ERR!       TS2339: Property 'useId' does not exist on type 'typeof React'.
ERR! Error: => Webpack failed, learn more with --debug-webpack
ERR!     at react-frontend/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:249:60
ERR!     at finalCallback (portal/react-frontend/node_modules/webpack/lib/Compiler.js:257:39)

Has anyone else encountered this and/or have a possible workaround?

@espada-edalex
Copy link
Author

Pretty sure this should work, but now it's throwing an error that it doesn't know the type of useId

const useId = "useId" in React
  ? React.useId
  : (() => {
    let i = 0;
    return () => `${i++}`;
  })();
ERR! [tsl] ERROR in react-frontend/node_modules/react-file-icon/dist/react-file-icon.esm.js(172,12)
ERR!       TS18046: 'useId' is of type 'unknown'.

The actual hack I made looks like this

var useId = "useId" in React ? React.useId : function () {
  var i = 0;
  return function () {
    return `${i++}`;
  };
}();

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

1 participant