Git Product home page Git Product logo

nvim-dap-reactnative's Introduction

Welcome to NVIM Dap React Native ๐Ÿ‘‹

Standalone debug adapter protocol for react native. Hopefully won't have any specific editor/ide stuff

Install

git clone [email protected]:sultanahamer/nvim-dap-reactnative.git

Run the debugger

  1. Set up the debugger with the following configuration, your configuration may be different but the values must match.
-- using modules
M.config = {
	adapters = {
		type = "executable",
		command = "node",
		args = { dbg_path .. "vscode-node-debug2/out/src/nodeDebug.js" },
	},
	configurations = {
		{
			type = "node2",
			request = "attach",
			program = "${file}",
			cwd = fn.getcwd(),
			sourceMaps = true,
			protocol = "inspector",
			console = "integratedTerminal",
			port = 35000
		},
	},
}

-- OR
-- directly - typescript react example

dap.adapters.node2 = {
	type = "executable",
	command = "node",
	args = { os.getenv("HOME") .. "/vscode-node-debug2/out/src/nodeDebug.js" },
}


dap.configurations.typescriptreact = {
	{
		name = "React native",
		type = "node2",
		request = "attach",
		program = "${file}",
		cwd = vim.fn.getcwd(),
		sourceMaps = true,
		protocol = "inspector",
		console = "integratedTerminal",
		port = 35000,
	},
}
  1. Run tsc from the debuggers directory inside this project's directory.
  2. Start react native metro bundler and make sure its running on 8081
  3. Run RN_DEBBUGER_WD=<project_directory> node src/standalone.js
  4. Now run the app in emulator, once it is running put the app into debug mode. Once in debug mode you should see the output in the image below in the terminal running the debugger
  5. It would wait on a white screen for debugger to attach, if its not a white empty screen then something didn't go well
  6. Now in neovim, setup your breakpoints and run dap continue :lua require('dap').continue().
  7. It should start with a debug waiting on some unknown location, ignore it and do continue :lua require('dap').continue(), it will again stop on another unknown location, do continue. Now it should start hitting the app's breakpoints
  8. When you finish debugging, if you make code changes, don't just refresh app, close the current debug session with :lua require('dap').close() Open emulator and hit rr, it will refresh and wait on white screen Do dap_continue or runlast and you are good to go

Debugger output when connected

Connected to the debugger

Author

๐Ÿ‘ค sultanahamer

Show your support

Give a โญ๏ธ if this project helped you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.