You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my components (my TodoList component), I'm trying to set a breakpoint on a line where two variables are destructured from this.state in a form submit callback. The relevant code for the component is below:
importReact,{Component}from'react';importTodoItemfrom'./TodoItem';lettodoId=1;exportdefaultclassTodoListextendsComponent{constructor(props){super(props);this.state={todoValue: '',items: [],};}onChange=event=>{this.setState({todoValue: event.target.value,});};// -----------------------------------------// THIS FUNCTION HERE --vaddItem=event=>{const{ todoValue, items }=this.state;// I'm trying to set a breakpoint on this linethis.setState({todoValue: '',items: [...items,{value: todoValue,id: todoId++}],});event.preventDefault();};// -----------------------------------------render(){consttodoItems=this.state.items.map(todo=>(<TodoItemvalue={todo.value}key={todo.id}/>));return(<divclassName='todoList'><formonSubmit={this.addItem}><inputtype='text'onChange={this.onChange}value={this.state.todoValue}placeholder='Enter a task'/><inputtype='submit'value='Add'/></form><ul>{todoItems}</ul></div>);}}
My VSCode launch config is the following (launch.json):
{
// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
}
]
}
(I tried making the example smaller, but somehow the issue always got fixed when some lines were moved around or removed. This leads me to wonder whether this is some sort of source map issue)
arnavb
changed the title
Breakpoint get moved down when Chrome debugger is launched
Breakpoint gets moved down when Chrome debugger is launched
Jul 5, 2019
Describe the bug
In one of my components (my
TodoList
component), I'm trying to set a breakpoint on a line where two variables are destructured fromthis.state
in a form submit callback. The relevant code for the component is below:My VSCode launch config is the following (
launch.json
):Here is a video illustrating what happens with my breakpoints: https://drive.google.com/file/d/1hTlCNSEY0eASSdyrOku1sC0yRPXnWhsB/view?usp=sharing
(The video may not be visible initially because it's being processed, but it should be downloadable).
Did you try recovering your dependencies?
Yes
npm -v
output:6.10.0
Which terms did you search for in User Guide?
Breakpoints, debugging, which both led to this and then from there I found this, which doesn't help me all that much.
Environment
Steps to reproduce
git clone https://github.com/arnavb/react-todo-app
code -r react-todo-app
.launch.json
code from above into.vscode/launch.json
(Create it if it doesn't exist yet).npm start
in the integrated terminal. Don't start Chrome debugger yet.src/TodoList.js
and set a breakpoint on line 23 (const { todoValue, items } = this.state;
).Expected behavior
The breakpoint wouldn't move and I would be able to hit it when I click the
Add
button in my todo list.Actual behavior
The breakpoint is moved down to line 25. When debugging, line 23 is just skipped.
Video demo: https://drive.google.com/file/d/1hTlCNSEY0eASSdyrOku1sC0yRPXnWhsB/view?usp=sharing
Reproducible demo
(I tried making the example smaller, but somehow the issue always got fixed when some lines were moved around or removed. This leads me to wonder whether this is some sort of source map issue)
https://github.com/arnavb/react-todo-app
The text was updated successfully, but these errors were encountered: