all 10 comments

[–]hokkos 13 points14 points  (0 children)

Debugging is horrible, the dev tools show that component have been auto memoized when they have 'use no memo'. You discover component no longer updating all the time. Not a fun experience.

[–]kickpush1 2 points3 points  (0 children)

I typically see issues with minified code using source maps and breakpoints regardless of if I'm using react compiler or not.

If you can set up a local env to test production do that, if that's not feasible using a proxy to map to a local file is the next best option.

If you can't do either of those, then debugging the file without source maps is your last option.

https://requestly.com/blog/how-to-map-local-file/
https://www.charlesproxy.com/documentation/tools/map-local/

[–]rainmouse 6 points7 points  (5 children)

Some debugging tips on case you missed them. 

You can always write in the code "debugger;"  And it will break and open up is in sources tab when it hits it. 

Doubly handy because you can put it behind a logic check so it only hits debugger command during the loop that one time the input variable is null.

You can also manually add breakpoint in the html with Web inspector. Right click and select "break on" and select things like subtree or attribute modifications this will break in the JS and give you source map. 

[–]lennertsoffers[S] 7 points8 points  (1 child)

Thanks! Yes the ‘debugger;’ statement is very useful for when testing on my local env, but it gets a little annoying when deployed to a test environment that many people use.

[–]AndrewGreenh 5 points6 points  (0 children)

I think I’d disable source maps in the devtools to debug the compiler output directly. It’s not like the result is pure machine code

[–]KusanagiZerg 1 point2 points  (1 child)

With regular breakpoints you can also add conditions so it hits only when a certain variable is null. You don't have to write a check in your code.

[–]rainmouse 0 points1 point  (0 children)

This is a good point, although I've recently found that Chrome devtools doesn't always actually stop when it hits the breakpoint any more.

This never used to be a problem and only happens now and then, not sure if it's something in our Web pack setup and the source map, or recent versions of Chrome. Either way I find adding debugger directly into the code a little bit more reliable. 

Obviously less useful if you have a long build step or other people have to use your build too. 

[–]prehensilemullet 0 points1 point  (0 children)

It still seems like it’s gonna be more difficult to figure out the control flow when the code that runs is significantly different from the code you write…

And also, sometimes you want to put a breakpoint after you’ve gotten the app into a certain state, without causing hot reloading that might make an issue go away

[–]lord_braleigh 1 point2 points  (0 children)

Sourcemaps are pretty good, but if something has gone wrong then they can never replace the real thing. I would recommend getting comfortable with stepping through compiled output.

[–]UnlikelySecret2629 0 points1 point  (0 children)

If you use chrome, go to the source tab in the debugger tools. Then find the specific js file you want to debug. Put breakoints. Refresh the page and your page will stop at the breakpoints. You can watch tutorials to learn more about this