7
u/tizz66 Sep 27 '20
Why is this a video? 🧐
1
-9
u/sharifimehr Sep 27 '20 edited Sep 28 '20
These were the four slides. Turned into video here by mistake. I did not want to take your time, next time I will just put the text.
7
u/billcosbysbutt Sep 27 '20
You could at least provide more detail and help others learn.
From the React Native docs:
Console.log statements
When running a bundled app, these statements can cause a big bottleneck in the JavaScript thread. This includes calls from debugging libraries such as redux-logger, so make sure to remove them before bundling.
2
2
u/UxmanKaxmi iOS & Android Sep 28 '20
Correct me if I am wrong? Doesn't babel automatically ignore all the "console.log" when making a release build?
1
u/sharifimehr Sep 28 '20
Yes, you can use "babel-plugin-transform-remove-console" , although some people have problems with it here: https://github.com/facebook/react-native/issues/10412 , but it is probably solved in the new version.
0
u/bladefinor Sep 27 '20 edited Sep 27 '20
So fucking tired of my colleagues forgetting to remove their console logs. Whenever I'm not part of a sub-project and I have a look at the release build in production there are plenty of console logs... It's so unprofessional I can't believe what got them to their position they're in.
Btw, I'm a consultant so I don't have much influence to the colleagues that are actual employees. I can remind them (and boy have I reminded them), but that reminder is long gone in the next project.
1
Sep 28 '20
I used to have a helper function which was console.log wrapped in an
if (__DEV__)check, but switched to using a babel plugin to strip console.* on production builds.If you rely on people removing things, it won't get done.
1
u/bladefinor Sep 28 '20 edited Sep 28 '20
This will of course do the trick in production. But that will also allow developers to forget that they are bloating the source code with stuff like:
console.log("asd”)
console.log("aaaaaaaaaaaa", value)
console.log("========")
console.log("result=", result)
I’m not joking, this is what I have to deal with when I share projects with others. They never remove their test logs. Even after the problems are solved, the logs will persist.
This might be a cultural problem at the company I’m current stationed at. But I’ve honestly experienced the same at previous companies I’ve been to.
2
Sep 28 '20
Sounds like the solution is to have someone in charge of merge/pull requests so these problems can be caught before they hit the main branch.
1
u/ironfist100X Sep 28 '20
you need to establish a rule in your project , so you dont have to worry this issues.
Have a linter in the project
https://eslint.org/docs/rules/no-console
2. Create a pre-commit hook that would check before commiting to github or any repo
14
u/VisualFanatic Sep 27 '20
25 seconds for just one paragraph? Having a few console.logs in a production build will not slow your app down, having a lot of them in a short amount of time will.