Intellij React Native node_modules dependency breakpoint not hit - react-native

I am using expo bare workflow (unimodules) and I would like to debug an issue by using breakpoints in react-navigation-stack, which lives under node_modules.
For coding and debugging I use Intellij. I have unchecked Do not step into library scripts and Do not step into scripts. I have also added react-navigation-stack as a library.
The problem is that my breakpoints for react-navigation-stack are ignored (they do not have a checkmark), but in rn_range_slider are hit normally (they have a checkmark).
Can anyone help?
Idea1:
It might have to do with metro's sourcemaps. I don't know how expo uses metro configuration and how to override it.
EDIT:
I added a photo from react native debugger, it seams metro loads lib/module target build, and breakpoints work
and from IntelliJ, lib/module breakpoints work, but src/(typescript) do not)

Related

Enable React Native Developer Menu in Release

This answer does not work in reality. It seems that NativeModules.DevMenu.show() is not working in the release build. Any lead on this?
The React Native Developer Menu will not work in the release mode, because of the following line of code in this file in the react-native source code :
if (__DEV__)
This checks if you're in development mode, then it emits the event for dev menu. The codes are of course added into the release.
If you really do want to use in release mode, then you can fork the react-native repo and patch this line and use your own personal copy of react-native.

How to remove react native navigation by wix

I'm working on a React Native project that use wix/react-native-navigation for the navigation and i hate it. I would like to remove this library but reading the documentation i found that the installation of wix RNN require changes to the android and ios folders and you must also run some command that make automatic changes to the project. Is there a way to entire remove the library and return to the initial situation?
You can follow the manual installation steps in reverse order, it worked for me. Revert these files android/build.gradle, MainActivity.java, MainApplication.java and index.js. Also run npx pod-install and remove all imports of react-native-navigation and all community libraries related to rnn from your code.

What can I look for to check if a project is set up as a "managed Expo project"

I'm trying to understand React Native development environment. I'm using Visual Code in Windows.
I've got a simple project A that I set up using the Expo tutorial as a "Managed Expo Project". Just a simple page and I'm trying to use a checkbox component.
I've got another inherited React Native project B, and I want to find out if it's a "Managed Expo Project" or a "Bare React native" project. It does include Expo, but I have read that even a Bare React Native Project can include expo.
So: Is there a setting on a line in a config file somewhere that makes it one or the other? ie Does the existence of "expo": "~40.0.0", in dependencies in package.json define it?
(I came to this point because I'm trying to use CheckBox from "#react-native-community/checkbox". Project B builds fine when using this, but my simple project A does not. I see on Expo website that this does not work with Expo, and that we are supposed to use a component Expo-Checkbox instead. SO I wanted to confirm the 2 projects are both expo-managed.)
Thank you.
Run expo diagnostics in your project and it will tell you what workflow you're using. The heuristics used to determine your project type are:
do you have an ios directory or android directory?
do you have react-native-unimodules in your package.json?
Usually people end up with a bare workflow project by accident when they eject and then don't properly revert their project once they decide to abort.
npm install expo-env-info
npm expo-env-info
Outputs
...
Expo Workflow: bare

What is react-native link?

What is the purpose of the react-native link command?
Note: from React-Native 0.60.0 linking packages using react-native link has become redundant. Autolink has been added to the React-Native CLI which means that iOS will now use cocoapods and Android will use gradle. You can read more about Autolinking here.
What is react-native link?
react-native link is an automatic way for installing native dependencies. It is an alternative to manually linking the dependency in your project. It works for both Android and iOS.
When linking a project manually the majority of the steps are the same and so using react-native link allows you to install the native dependency with less fuss and without having to type similar code or perform similar actions repeatedly.
However, it should be noted that running react-native link will not always link a package fully, sometimes additional steps are required and you should check carefully with the installation instructions.
Always read the instructions carefully before installing a dependency and linking it.
iOS Considerations
If your project is using CocoaPods and the dependency that you are linking has a .podspec then when you use run react-native link it will update your Podfile. This is instead of adding the files directly to your Xcode project. You will also have to run pod install inside your ios directory otherwise the native dependency won't be fully installed.
Sometimes installing using CocoaPods can cause more issues, and not every dependency needs to be installed with CocoaPods you could always follow the steps that I outlined in this SO answer to stop react-native link adding a dependency to the Podfile, it is not ideal but it is a workaround. Some dependencies require additions to be made to the Podfile, so you should only do this if the dependency doesn't require pods to run.
react-native link or react-native link dependency-name
Should you just use react-native link when linking any dependency or should you be more explicit and use react-native link dependency-name?
From my experience it is better to use react-native link dependency-name. This is due to the fact that react-native link will try to link (or re-link) all the dependencies that can be linked and this can lead to code duplication. Most of the issues that I have experienced have been when the Android native dependency is being linked. I think there has been some headway in stopping this from happening in subsequent updates, but the old adage applies here once bitten, twice shy
Linking good practice
When using react-native link dependency-name you should follow good practice so that you don't get stung. Sometimes dependencies that you try don't work as expected and removing all the code that was added during the linking process can be tricky. (Xcode project files can be a nightmare to go through if you are unfamiliar with them).
This is how I install dependencies and then link them.
Make sure that you are using version control, like git.
Make sure your code is fully committed with no unsaved changes.
Create a new branch, and check it out.
Install your dependency npm i dependency-name
Then link you dependency react-native link dependency-name
Perform any additional installation steps that the dependency requires. See the installation instructions for the dependency.
Check that your code works with the new dependency.
commmit changes and merge the branch.
Manual Linking
If you prefer to link your native dependencies manually then you should either follow the instructions on the dependency's website or you can look at the documentation that react-native provides.
Currently there is only an explanation on how to manually link iOS projects.
Manually linking Android requires you to make changes in the following locations:
settings.gradle
app/build.gradle
MainApplication.java
As always for the exact changes that you should make you should look at the dependency's manual linking instructions.
Do I have to link?
It depends on the dependency that you are using some dependencies use only code written in Javascript, so it is not required to link them, and there is no benefit served by running react-native link dependency-name.
However, if the dependency contains native code then you will have to link. Either manually or by using react-native link dependency-name.
How can I tell if I need to link the dependency?
Firstly you need to check the website, the github repo, or the npmjs.com page for the dependency. There will usually be instructions there telling you whether to link the dependency after you have installed it.
If you cannot find any instructions about linking, you (probably) won't need to link it.
If you are still unsure, check with the dependency maintainer.
Can I just run link anyway?
Yes, you can it won't do anything if there is nothing to link. But always run it with react-native link dependency-name to avoid issues.
When do I run link?
You only run it after you have installed your dependency. I would recommend running it just after you have installed the dependency. You should then check to make sure that it works, before installing any new dependencies so that you can easily debug.
You shouldn't need to run it more than once per dependency.
It doesn't matter how many components or changes to the javascript code that you make it won't affect the linking, as the linking is purely native and components are javascript.
What is autolink?
Autolink is a new feature that is being added to the react-native-cli. You can read more about autolink here.
Autolink replaces react-native-link
Autolinking is a mechanism built into CLI that allows adding a
dependency with native components for React Native to be as simple as:
yarn add react-native-webview
Autolinking is a replacement for react-native link that brings new features (such as ability to easily integrate native dependencies on iOS) and fixes some of the long-standing issues.
Once it is fully implemented it should make adding dependencies with native-code to your project much easier.
Linking native library means that you are going to integrate already implemented module into your application or module which completes your react native's module functionality.
Steps to integrate lib(android):
1) Add package name to new packages() 2) Add dependencies to settings.gradle file and main application's gradle i.e app/gradle file. 3) sync the projects gradle because you made changes in the gradle and it's done.
All manual steps like below you have to perform
1) Go to your project's home dir using cmd.
2) run npm install
3) Thereafter run rnpm link or react-native link
4) see ios folder in your project folder and if you find any pod file then run pod install after navigating into ios folder in cmd.
now instead,
1) Go to your project's home dir using cmd.
2) run npm install
3) Thereafter run rnpm link or react-native link
4) see ios folder in your project folder and if you find any pod file then run pod install after navigating into ios folder in cmd.
When you've installed a library with native content(android or ios) then you need to require linking to the component react-native library.
like this
react-native link react-native-sound-player
When you installed any third party library with native content,you have to link the dependencies in android and ios. react-native link is responsible for including the dependencies in gradlew and pod files.
for suppose you installed react-native-vector-icons package then you have to link in your gradlew files. the new version of react native 0.60 has auto linking.
npm install react-native-vector-icons
react-native link react-native-vector-icons
Thanks for asking this question
if you are working with fonts
react-native link is used for linking the fonts and assets to project
link command is also for linking the libraries to react-native
But now React-native too better so there is no need to link the library
we can use
pos install
npx jetify
it will automatically link the libraries
react-native link is an automatic way for installing native dependencies. It is an alternative to manually linking the dependency in your project. It works for both Android and iOS

Debug a react-native application using nuclide

Is there any good document/video that talks about how to debug a react-native application using Nuclide.
Am a newbie. Its my first time app development and first time with React.
I did create the project using react-native init. I don't think i found a BUCK file for me to run and debug my app. I also don't see to get how to view the errors in my JS file. I have to run the simulator to see. I run it using react-native run-ios.
I tried Nuclide->React Native->Start Debugging. Not sure what this is supposed to do.
Sorry if these questions sound silly.
According to this instruction you should:
From the command Palette (Cmd-Shift-P) choose "Nuclide React Native: Start Packager" to start the React Native Server.
Ensure that you are in the root directory of the React Native project, then run the application from the command-line: "$ react-native run-ios" (or choose other existing simulator, for example react-native run-ios --simulator="iPhone4s").
After starting the server, you can prime the React Native Debugger for when the application begins running. From the command Palette (Cmd-Shift-P), launch "Nuclide React Native: Start Debugging".
From the Simulator press Cmd-D (Ctrl-D on Linux). This will bring up the debug options for your application. Select "Debug JS Remotely.
...After you enable debugging from the simulated application, Nuclide will attach to that debugging process automatically, since we primed the Debugger above.
Debug JS in Nuclide is now an option in the dev menu added in React Native version 0.52 December 2017 release.
See This