Hi - first time poster here, so will try to do this right!
I have deployed my site, which was built using React+Vite, and I’m not getting any errors. I have a specific component which is accessed using the “Opportunities” link. This is supposed to load a list of job opportunities, and each one has a grey star which is used to toggle the job ad as favourite for the user.
The codebase is here and login instructions are in the readme. The specific issue is coming from src/components/Opportunities.jsx (line 161: displayFavouriteIcon
function). I don’t want to be so specific as I know it’s not your job to review my code but I also give you the information as mentioned in the help guide.
Here’s what’s happening - if I access the page mentioned when using the local development server, it works completely fine. But on the deployed site, the page crashes and the console provides this error:
react-dom-B-QKN3I2.js:16 TypeError: Cannot read properties of undefined (reading ‘createElement’)
As the file reference which is throwing the error is from the minified code, I can’t debug exactly what the issue is.
Here are some of the steps I have attempted to resolve the issue (note the favourite status is dependent upon the component having access to the current user object, one of the properties of which is listingsFavourites
:
if
condition in code to only render the component if the user object is notnull
orundefined
- Changed the
favourites
variable to be stored as a state object (faveData
) - Added a
loading
state object which would provide a temporarydiv
to be shown whileloading
istrue
- Tried React’s
Suspense
andlazy
loading feature (in App.jsx) to force a Loading component to be shown while waiting for the Opportunities component to become available - Accessed website through BrowserStack (tried Safari, Chrome, Edge - all with the same result)
- Tried changing Node.js version to 18.20.3 (using npx in terminal and updating Netlify dependency settings in browser)
- Added environment variables and set up Netlify CLI so that I could run a Netlify development server to test the issue (note: the site works fine using this dev server and does not throw the type error)
- Updated React/React Dom version in package.json to match version number shown in npm list (now 18.3.1 - was 18.2.1)
I was going to include a zip file showing the most recent deploy log, but the system won’t allow me to include any attachments. I’m not sure if this is necessary as there are no errors, but if so let me know and I can paste it.
Packages installed:
fuse.js
ionicons
tailwindcss
react/react-dom/react-router-dom
vite/vitest
jsdom
pexels (images)
Thanks in advance,
Kelly