axe-core-npm icon indicating copy to clipboard operation
axe-core-npm copied to clipboard

Uncaught (in promise) TypeError: Cannot set property createElement of [object Module] which has only a getter

Open dariolingotti opened this issue 3 years ago • 4 comments

Uncaught (in promise) TypeError: Cannot set property createElement of [object Module] which has only a getter at reactAxe (index.js:334)

Product: @axe-core/react

Expectation: shows in console invalidations

Actual: Console shows: index.js:334 Uncaught (in promise) TypeError: Cannot set property createElement of [object Module] which has only a getter at reactAxe (index.js:334) at Module../src/launch-axe.ts (launch-axe.ts:6)

Motivation: I want to have compability with https://cdn.jsdelivr.net/npm/[email protected]/umd/react.production.min.js


axe-core version: 4.2.3
@axe-core/react: 4.2.2

- Node version: v12.21.0
- Platform:  Windows

dariolingotti avatar Jul 06 '21 20:07 dariolingotti

Any updates on this? Getting the same error message Cannot set property createElement of [object Module] which has only a getter

This is for a React 17 + TypeScript 4.4 + Webpack 5 project.

adamtay avatar Dec 06 '21 00:12 adamtay

We are currently investigating this issue and will have an update soon!

michael-siek avatar Dec 08 '21 01:12 michael-siek

We managed to get it working by using a default import statement of react/react-dom instead.

Not an ideal solution but is sufficient as a temporary workaround for now.

Before:

import * as React from "react";
import * as ReactDOM from "react-dom"

After:

import React from "react";
import ReactDOM from "react-dom";

adamtay avatar Dec 08 '21 01:12 adamtay

Same issue using preact/compat, but the workaround does not seem to work

PepeBotella25 avatar May 16 '24 15:05 PepeBotella25