Jarda Šnajdr ![rw-book-cover](https://s0.wp.com/i/blank.jpg) ## Metadata - Author: [[Jarda Šnajdr]] - Full Title: Jarda Šnajdr - Category: #articles - Summary: The content discusses the importance of using real timers instead of fake timers when testing React components with Testing Library. It also touches on topics such as Redux Thunks, optimizing @wordpress/data usage, CPU architecture effects on code performance, and optimizing JavaScript code for JIT compilers. - URL: https://jardasn.blog/ [Skip to content](https://jardasn.blog/#wp--skip-link--target) * When testing React components with Testing Library, we should always be using real timers. Fake timers should be a rare exception. Let me offer some reasons why. The philosophy of Testing Library is that it runs your React code in an environment as close as possible to the browser. React components are rendered using the… * At the end of the Motivation for Thunks post we arrived at a thunk function that fetches stuff from a REST endpoint and stores it into state by dispatching an action: This is a good JavaScript function that’s going to do the fetching and receiving, and the return value from the thunk is available as… * The redux-thunk package is by far the most widely used middleware in Redux, and now our own @wordpress/data package also supports its own flavor of thunks. Yet the concept of thunks is often poorly understood, the motivation for them is unclear, and they are thought of as something magical. In this section I will show… * During a recent debugging session where I was trying to discover why e2e tests for code that uses @wordpress/data are failing, I found out that we often use the useSelect hook in a suboptimal way. One that either introduces outright bugs, or is slower and causes more React rerenders than it needs to. In this… * Yesterday I attended C++ meetup regularly organized by Avast folks in their Prague offices. There was a great talk by Jakub Beránek, a talented CS student from Ostrava, about observing performance effects that the internal CPU architecture has on your code. In this awesomely organized and documented repo, there are C++ benchmark programs that demonstrate… * Here is an awesome article about optimizing JavaScript code for JIT compilers. Describes techniques on how to extract information on where V8 spends time, and most of them are surprisingly accessible to someone with little optimizing-compiler skills. Then Shu-yu Guo retweeted it with a link to their paper about Optimization Coaching in devtools. There is…, Jarda Šnajdr, Jarda Šnajdr, 01hr8herbtbvr5vjb80fr4xp1s.