Home > Net >  Corrupted React component name?
Corrupted React component name?

Time:09-03

This is an unusual one.

I commited a git branch, merged it, then hit undo on the merge. If I roll back to the commit (that had just been working) I get the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'includes')
    at UniqueComponentName (UniqueComponentName.js:13:1)

Line 13 is the opening declaration of the functional component:

export const UniqueComponentName = ({ side, mode, menuJSON, pcbData, ...props }) => {

I thought, initially, it was a problem with an 'includes' in the component but trial and error led me to discover the following:

  1. A brand new component named UniqueComponentName, made with a template that works under any other name, still throws this error.
  2. If I don't include the UniqueComponentName component in any other component, the app performs fine.
  3. As soon as I include it, the error above is thrown. Again, the contents of UniqueComponentName are irrelevant as I can literally copy and paste another working component and the error comes up.

I'm wondering if it's possible that the merge and undo merge corrupted some reference to UniqueComponentName? It's a long shot, I'm aware, but I'm there has been a lot of work since the last commit.


Further info:

If of relevance:

  • Reactjs is running off the standard create-react-app server locally.
  • I have been staging commits locally, and using a 3rd party build pipeline to run builds on anything I push to github. The builds are hosted an a remote server that isn't involved here. As far as I know, there's no production builds locally : I just hit save on any file as I'm working on it and see webpack compiles, browser updates, etc.
  • I'm considering starting up a fresh create-react-app project and bringing in all the /src files from the current project, to see if mt theory holds up.

CodePudding user response:

The error is caused by create-react-app serving old bundle files.

Those files are located in the node_modules/.cache/ folder.


Solution;

  1. Delete the node_modules/.cache/ folder
  2. Restart your dev-server

React should now re-create all the bundle files, sourcemaps, etc..


- Old git issue with some in-depth details

  • Related