React : Invalid hooks call without changing the React code - javascript

I am working on a full-stack app. My front-end, built on React was working fine. I installed cors for my back-end and it suddenly started giving me Invalid hook call error in my react app.
I tried uninstalling the dependency and also reverting to 2 old commits but it didn't work. I'm thinking it might be because of a peer dependency causing multiple versions of React. I tried npm ls react and npm ls react-dom but I have only one version for each i.e. 17.0.2.
The error message is also not helpful as I cannot understand where to start digging from. Attaching it below.
Here's the code repo (I couldn't figure out which part of code to share). The React code is inside the client directory. If someone can pinpoint me where to look or help me with the issue I'll be obliged. Thanks!
Error message

Related

Unable to fix Node Path in packaged Electron App

I'm building a simple Electron app for MacOS (using React as the frontend). The purpose of the app was to make executing certain terminal commands a lot easier (using child_process.spawn. Primarily I am interested in using the sfdx Salesforce CLI commands.
When I run the app in dev, everything works fine. However when I package the app, the PATH variable gets changed and I'm no longer able to locate the sfdx library. (*note it is still able to find git commands though).
I found a very similar issue here and a bug report in GitHub, both of which recommend the use of the fix-path package. This is where I run into another issue. According to the docs, I should import the package like this:
import fixPath from 'fix-path';
However when I do that inside of my electron.js file I get this error: SyntaxError: Cannot use import statement outside a module. I've seen other resources that use require to bring in the package:
const fixPath = require('fix-path');
But again, when I do that I get this error require() of ES Module not supported.
I tried adding "type": "module" to my package.json file, but that breaks my app as well.
I feel like there is something simple that I am missing here, but can't seem to figure out. I believe that if I could import and use the fix-path package, then this would solve my problems. But if that isn't possible, does anyone know of a way for me to fix the path in my app so that it works in prod?
Thank you in advance!
Some extra details:
The two dependencies I check for are git and sfdx. The following image shows where both of those live on my machine:
And this is the response to the same commands within the packages asar file:
I found a workaround, it looks like fix-path made a move to ESM during the last release. Because I am using CJS modules I just needed to install version 3 of fix-path by running npm install fix-path#3.0.0 --save

Unable to resolve module react-native-reanimated/src/core/AnimatedEvent

This is my first post so my apologies if I leave out some important details that will make it easier to answer the question.
As I was working on my project for my app development class I stumbled upon an error that I cannot fix/figure out what's causing it. I did not mess with any of the node modules and the app was working perfectly fine before the error message.
Image of error message
I have attempted to clear the cache, re install and update some of the packages that I needed for this project, and looked for any errors within the code of my project. No luck after 2 hours of attempts.
Are there any recommendations of that I need to do to fix this? Should I start the project from scratch again?
Thank you all!
Have you tried cd ios && pod install? Also, upload your package.json file
As the error suggests react-navigation-drawer is trying to find a component which doesn't exist. Implying your versions are out of sync.
I was able resolve this issue by upgrading react-navigation#4.0.0.

Expo eject from managed to bare not working

I created an app with expo using the managed workflow, but I now want to eject it so I can build an IPA for IOS. After running expo eject and following the prompts for pod install, when I try to build the app and view it on the simulator in xCode, I get stuck on the splash screen which results in a very long list of errors (attached the relevant looking one below).
Have I missed a step here? I tried looking on the expo documentation but it’s very lacking in using the eject command. Is there a step or something I’m meant to modify after the eject has occurred?
Error: Exception NSException * "expo-updates must be configured with a valid update URL or scope key."
So I resolved this by following these steps after I ejected: https://docs.expo.io/bare/installing-updates/
And also adding the below to the Expo.plist file in the MyApp/Supporting folder with the below:
<key>EXUpdatesURL</key>
<string>https://example.com</string>

Failed to apply patch for package

I tried to run a new React Native (Android) project I got from somebody. When I run yarn install, the following error happens. How can I fix this ? I am new to react native.
patch-package: Applying patches...
**ERROR** Failed to apply patch for package react-native-confirmation-code-input
This error was caused because Git cannot apply the following patch file:
patches/react-native-confirmation-code-input+1.0.4.patch
This is usually caused by inconsistent whitespace in the patch file.
For anyone having this problem, this isn't a React-Native problem per se, it's because the library patch-package is trying to apply a patch for "react-native-confirmation-code-input" and fails.
This is mostly caused when the patch is created in Linux/MacOS and then used in Windows, because of EoL differences.

Transformer hangs in recent versions of React Native when using Baobab

I started my React Native project with version 0.12.0 and Baobab. Everything worked great until React Native 0.14.2. In any version since then, the transform in the packager stops at 98% and the JS load fails.
I have used some of the advice in this github issue to determine that it's transforming a file in Baobab (baobab/dist/update.js or baobab/dist/watcher.js in different runs).
I have confirmed that Baobab is the issue by creating a clean React Native 0.16.0 install and only putting Baobab in it (with the required require)
At this stage, I'm not sure whether I should raise an issue with React Native or with Baobab, so I'm looking for advice on how to get some sort of error message that I can use to debug the issue and work out what's going wrong.
Ok. Worked this out myself:
By adding debug=babel to the environment the packager is running in, I got a huge amount of output and hidden in there was an error that .babelrc in the baobab package had an optional entry and the React Native packager doesn't understand optional. I deleted the .babelrc from the baobab package and everything works.

Categories

Resources