Skip to content
Skip to content
Menu
A cup of dev
  • Home
  • About
  • Contact
  • Books and ink
A cup of dev

React in ListViewCommandSet – how to fix the “Cannot read properties of undefined (reading ‘id’)” error

By Eli H. Schei on Wednesday, 6 August 2025, 7:32Wednesday, 6 August 2025, 7:51

This was one of those tiny issues I ended up spending way too much time troubleshooting—until I finally stumbled across the solution after a lot of searching. In my case, the problem was React in ListViewCommandSet for the SharePoint Framework (SPFx) not playing nicely due to a version mismatch.

It’s just long enough between each time I work with ListViewCommandSets that I remember having this problem before… but never quite remember how I fixed it. And of course, when I do need to fix it again, I end up going down a rabbit hole of forum posts, GitHub issues, and old documentation before finding the right answer.

This time, I’m writing it down, partly to save myself the headache next time, and partly in case it helps someone else.

The Problem

The issue came down to a version mismatch between the React version I had in my project and the one required by the ListViewCommandSet in the SharePoint Framework (SPFx).

I was using React 17.0.2, but the ListViewCommandSet specifically needs React 17.0.1. Even though these versions look almost identical, the SPFx build pipeline can be very picky about exact dependency versions. A minor mismatch like this can lead to cryptic errors, broken components, or commands that simply don’t appear in the list view.

And here’s the kicker—you can’t just rely on the existing React version in your project. You have to explicitly install the correct one, along with matching type definitions, or it still won’t work.

The fix

Here’s the exact command that solved the problem for me:

npm i react@17.0.1 react-dom@17.0.1 @types/react@17.0.45 @types/react-dom@17.0.17 --save-exact

The --save-exact flag is important—it ensures your package.json pins these dependencies to the exact versions, avoiding accidental upgrades that might break things again later.

Why This Matters

Working with SPFx (and especially ListViewCommandSets) often means playing nicely with Microsoft’s chosen dependency versions. While newer versions of React might work in other contexts, SPFx tends to lag behind slightly, and the tooling expects a very specific setup.

So, next time I start a project with ListViewCommandSets—whether it’s months or years from now—I’ll know exactly what to check first.

Here’s hoping this saves someone from the same headache. If nothing else, future me will thank me for writing this down!


If you are interested in Microsoft 365 Development you might also like my other blogposts in this category.

Also, if you have any feedback or questions, please let me know in the comments below. 🙂

Thank you for reading, and happy coding!

/Eli

If you want to support my content you can

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Post navigation

How to Get Site-ID with Graph Explorer (and other SharePoint info)
How to create columns in Dataverse using PowerShell

Leave a ReplyCancel reply

Eli H. Schei

I'm a front-end developer who mainly work in the Microsoft 365-sphere. As a developer I read a lot of blogs. And in my experience I can read multiple different blogposts about exactly the same topic, and only one of them makes sense to me. Therefore I’m adding my voice to the mix, and hopefully one of my blogposts will be the one that makes sense of a topic for you. You can learn more about me here.

Recent Posts

  • Package and deploy SPfx solutions using PnP PowerShell
  • Create an Entra ID App Registration for Interactive Login with PnP PowerShell When Working with SPFx Solutions
  • How to create columns in Dataverse using PowerShell
  • React in ListViewCommandSet – how to fix the “Cannot read properties of undefined (reading ‘id’)” error
  • How to Get Site-ID with Graph Explorer (and other SharePoint info)

Categories

  • Azure
    • Azure CLI
    • Azure functions
  • Level
    • Beginner
    • Intermediate
  • Microsoft 365 Development
    • Microsoft Authentication Library
    • Microsoft Graph
    • Microsoft Teams
    • PNP powershell
    • SharePoint Framework
    • SharePoint Online
  • Power Platform
    • Dataverse
    • PowerApps
      • PowerApps Component Framework
  • Tech Lead
  • Web development
    • Accessibility
    • Soft skills
    • Tips and tricks

Tags

accessibility app permissions ARIA azure Azure CLI azure functions Content creation custom themes dataverse Entra ID favorites git github ListViewCommandSet M365 CLI M365 development MS Graph PCF PnPjs PnP powershell power apps PowerApps Component Framework powershell quicktip react resources SharePoint Online Sideloading SPfx Teams teams app dev Teams apps Tech lead tools wcag webdev Windows terminal
©2026 A cup of dev | WordPress Theme by SuperbThemes.com