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

react: Support React v18

Open stephenmathieson opened this issue 3 years ago • 4 comments

Product: react Expectation: React v18 support and docs Actual: n/a Motivation: Upgrading an app to use React 18 and want to continue using @axe-core/react

stephenmathieson avatar Apr 22 '22 00:04 stephenmathieson

Need this too please, any update on when to expect it? Or any workaround until ready? Thanks!

another1aa avatar Jun 06 '22 11:06 another1aa

Below works for me in React 18. I guess the initialization readme needs to be updated for react 18 with below example

import React from 'react';
import {createRoot} from 'react-dom/client';

const container = document.getElementById('root');
const root = createRoot(container);

root.render(
    <div>Hello World</div>
);

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  const axe = require('@axe-core/react');
  axe(React, root, 1000);
}

saileshkotha avatar Aug 29 '22 03:08 saileshkotha

@saileshkotha doesn't work for me. Not sure why it does for you but I'm pretty sure this is not the fix.

mithodin avatar Sep 02 '22 12:09 mithodin

Any update on adding this support?

AustinGarrod avatar Oct 11 '22 20:10 AustinGarrod

It works for me if I import ReactDOM from react-dom/client. React and ReactDOM version:

"react": "^18.1.0",
"react-dom": "^18.1.0",

This is my index.tsx file:

// /* eslint-disable @typescript-eslint/no-non-null-assertion */

import React, { StrictMode } from 'react';
import ReactDOM, { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';

import store from 'store/store';

import App from './App';

if (process.env.NODE_ENV !== 'production') {
  const axe = require('@axe-core/react');

  axe(React, ReactDOM, 1000);
}

const container = document.getElementById('root');
const root = createRoot(container as HTMLElement);

root.render(
  <StrictMode>
    <Provider store={store}>
      <App />
    </Provider>
  </StrictMode>,
);

And result in console: image

damian08k avatar Nov 06 '22 17:11 damian08k

@damian08k it works on the initial render, but not on subsequent updates.

mithodin avatar Nov 07 '22 07:11 mithodin

@mithodin Yes, you're right. I didn't notice that. So maybe let's try to ping axe-core creator I belive @michael-siek

Is there any chance to update @axe-core/react to use in React 18+ projects?

damian08k avatar Nov 07 '22 17:11 damian08k

@damian08k We will be working on this soon to be able to support all React 18+ projects

michael-siek avatar Nov 11 '22 17:11 michael-siek

I'm also interested by a workaround, if any of you have a sample repo :D ... currently using Next 13 but I guess it's adaptable once working with React 18

Thank you,

sneko avatar Dec 05 '22 10:12 sneko

Also interested in this, we're waiting on implementing axe on this change

jkliptonia avatar Feb 07 '23 18:02 jkliptonia

@michael-siek Is there any update on this work?

jkliptonia avatar Jun 14 '23 17:06 jkliptonia

Thank you for your continued patience. We've looked into supporting React 18 but at this time it doesn't look like we will be able to. Between issues with React 18 and the deprecation of findDOMNode in strict mode we haven't been able to find a workaround that will allow running accessibility checks on changed nodes at page load and subsequent updates.

straker avatar Jun 14 '23 20:06 straker

Bumping this, as (1) react@18 adoption continues to grow; and (2) accessible UI is important.

I'm not looking for a 1:1 solution to restore the old behavior, nor do I have any to propose. I'm wondering instead how the Axe team recommends we implement Axe in a modern React project.

To be clear: I am very okay with tradeoffs like "deduplication gets worse" or "Axe always scans the whole page vs. just the changed tree". Mostly looking for a recommended path forward, as it's been almost 18 months since this issue was opened & 9 months since anyone was assigned.

anulman avatar Sep 14 '23 23:09 anulman

Can we get the readme updated to indicate this tool is incompatible with React 18 until support is added?

Bill-Compton avatar Jan 31 '24 21:01 Bill-Compton

Hello Axe-core team. Is there any update related with React 18? We need to update to React 18 and we are using Axe-core cli. iIs there a solution that we will be able to continue using it?

anagritsay avatar Feb 01 '24 13:02 anagritsay

Hi @anagritsay and folks following this comment thread. I'm a Product Manager at Deque and I wanted to make sure we we're communicating clearly on this issue.

Following on from @straker's earlier comment on June 14th, 2023, we have not been able to solve this problem. Furthermore, we have no plans to support React 18 and above. I will update the project's README to further communicate our plans.

What are the alternatives? Deque will be offering other solutions for developers writing automated tests in the JavaScript and Node ecosystems. During and immediately following axe-con (Feb. 20-22), there will be announcements about our recommended approach. I'll communicate alternatives within the project's README after product announcements have been made.

ballendq avatar Feb 06 '24 10:02 ballendq

Thanks for the update @ballendq. Excited to learn what you recommend! I wonder if it has something to do with MutationObservers

anulman avatar Feb 08 '24 03:02 anulman

Thank you for the information @ballendq, looking forward for the update

anagritsay avatar Feb 12 '24 09:02 anagritsay

Hello Where can I find the news which were presented at the axe-con? Best regards

AtuHQ avatar Mar 13 '24 13:03 AtuHQ

Hello Where can I find the news which were presented at the axe-con? Best regards

@AtuHQ, It looks like you can register for the conference (even though it's already past) to get access to the session recordings. I'm trying to find the session with any relevant information now.

https://www.deque.com/axe-con/register/

jlbooker avatar Mar 15 '24 13:03 jlbooker

Quick update from Deque - we'll have a product offering coming in late March/early April. The first release will focus on JavaScript/TypeScript testing frameworks. We're still working on the details of this release so there will be more to come when the "official" release is done. Once complete, I can point folks to a blog post etc.

The new product will have a free plan and I'll add more commentary to this thread to describe how this might be used in open source. The new release will also have paid plans so that it's suitable for company use. Again, more details coming soon.

ballendq avatar Mar 18 '24 12:03 ballendq

@ballendq Thanks looking forward to the update here!

kurtwaldowski-b avatar Mar 27 '24 14:03 kurtwaldowski-b

@ballendq any update? We're almost out of April.

AlwaysMoreHats avatar Apr 25 '24 21:04 AlwaysMoreHats

React 19 beta was just released, the question is it this will be fixed before it becomes obsolete?

AnderssonPeter avatar Apr 26 '24 05:04 AnderssonPeter

@AlwaysMoreHats

@ballendq any update? We're almost out of April.

Yes, early next week. Very end of April.

ballendq avatar Apr 26 '24 10:04 ballendq

React 19 beta was just released, the question is it this will be fixed before it becomes obsolete?

@AnderssonPeter see my comment from Feb 6th 2024

ballendq avatar Apr 26 '24 11:04 ballendq

Folks - we released a new product called axe Developer Hub. This product has numerous JavaScript/TypeScript test framework integrations and is Deque's recommended path forward for users of this library who wish to use more modern versions of React.

The product has a free plan where each licensed user gets 1 API key. This is a good option for open-source projects or solo developers looking for high-quality accessibility feedback. Sign up for the free plan.

For more information, read the recent blog post: Introducing axe Developer Hub, now available as part of axe DevTools for Web

ballendq avatar Apr 30 '24 16:04 ballendq