title: How can I reset a react component including all transitively reachable state?
body: <p>I occasionally have react components that are conceptually stateful which I want to reset.  The ideal behavior would be equivalent to removing the old component and readding a new, pristine component.</p>
  
  <p>React provides a method <code>setState</code> which allows setting the components own explicit state, but that excludes implicit state such as browser focus and form state, and it also excludes the state of its children.  Catching all that indirect state can be a tricky task, and I'd prefer to solve it rigorously and completely rather that playing whack-a-mole with every new bit of surprising state.</p>
  
  <p>Is there an API or pattern to do this?</p>
  
  <p><strong>Edit:</strong>  I made a trivial example demonstrating the <code>this.replaceState(this.getInitialState())</code> approach and contrasting it with the <code>this.setState(this.getInitialState())</code> approach: <a href="https://jsfiddle.net/emn13/kdrzk6gh/" rel="noreferrer">jsfiddle</a> - <code>replaceState</code> is more robust.</p>