Open sourced: a utility for shallow rendering React components

Jul 06, 2016

After lots of copy/pasting a small utility that makes shallow rendering a React component a little easier, I decided to open source it. It’s called renderShallow, and it's now on Github and npm as render-shallow.

My motivation for it came when I started noticing that in most of the React component tests I wrote, I simply wanted a shallow rendered component to test. The ShallowRenderer API is a little verbose, between the creation and the getting of the output. So I started abstracting that (the .output returned from renderShallow). When I found myself wanting to rerender the component, either because of state or props changes, I added the ability to both re-fetch the output (rerender), or render the element again with new props (rerenderElement).

This post originally appeared on Ian's blog. If your company has a React project you need help with, please contact us!

You May Also Like

These Stories On Technology

Josh Seiden, the fourth speaker in Stride's Leadership through adversity speaker series, spoke about the value of focusing on outcomes, defined as: "measurable changes in behavior that drive business results."   read more

To start his talk, psychiatrist and psychoanalyst Dr. Kerry Sulkowicz admitted to being at a bit of a loss when asked about best practices for leading through a pandemic. "The honest answer is I don't know," he stated, "because none of us has lived ... read more

Taking direct aim at the narrative of the "all in" entrepreneur who takes extreme risks and depletes their bank account before ultimately succeeding, noted NYC VC Charlie O'Donnell started his Stride Consulting “Leading through Adversity” talk on May ... read more

In response to these unprecedented times and the challenges that they are bringing to company leaders, Stride Consulting launched a speaker series entitled “Leading through Adversity” on May 26th. In the series, experts from around the globe, from a ... read more

Get Email Updates