Issue 1:
Do you want to request a feature or report a bug?

I would consider it a feature 😈

What is the current behavior?

React does not put any limits on recursive rendering, using higher-order components. However it does so for calling this.setState(...)

It reproduces pretty easy with a pair of a Container and an HOC:

https://github.com/sergeysolovev/react-bomb/blob/master/src/index.js

I wouldn't try this on CodeSandbox or JSFiddle (I did). Here is the code:

import React from "react";
import ReactDOM from "react-dom";

// Accepts a component as a prop and renders it
// passing the props through. In a real life scenario
// usually does something more than that
const Container = props => {
const { component: Component } = props;
return <Component {...props} />;
};

// An HOC-version of Container
const withContainer = WrappedComponent => props => (
<Container component={WrappedComponent} {...props} />
);

// Though it looks a bit artificially here,
// it's pretty common to use something like `compose`
// which does the same thing but looks more innocent
const Bomb = withContainer(withContainer(() => null));

class Detonator extends React.Component {
state = {
wentOff: false
};
goOff = () => this.setState({ wentOff: true });
render = () =>
this.state.wentOff ? (
<React.Fragment>
<Bomb /> Oooppps... This text probably wont be rendered
</React.Fragment>
) : (
<button onClick={this.goOff}>Lets see</button>
);
}

ReactDOM.render(<Detonator />, document.getElementById("root"));

What is the expected behavior?

I would expect to have some limit on such kind of recursion, because it's blazing fast (like React's supposed to be), eating lots of RAM in short time and a bit difficult and annoying to stop.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Reproduces on Chrome 65. I've done it for React 16.3.1 and 16.3.2

Issue 2:
Do you want to request a feature or report a bug?

Feature (possibly bug?)

What is the current behavior?

I've been trying out the new Context API in my project and it's awesome. However, in my haste to start using it, I managed to stumble into a situation where every time I would try and render a certain component which was making use of a few different contexts, the app would completely freeze, and the only thing that would let me get out of this error state was to forcefully kill the process via the chrome task manager.

Nothing would be logged to the console, the app would just completely freeze, and when I opened up the task manager and saw the CPU spiked up every time i would go to this component, and the only way I could stop it was to crash the tab.

I finally threw some console statements in and saw that it had just entered into an infinite loop between these providers. I managed to get the app to stop crashing, but I'm still unsure as to why exactly this was happening. I'm sure I was just using this API incorrectly somehow, but this was a very confusing problem to diagnose, and some error checking here would be incredibly useful

What is the expected behavior?

It would be very beneficial to have some sort of checks in place, similar to what happens with too many setState calls happening too closely when you call it from componentDidUpdate, for example. That way, instead of freezing everything up permanently, the app could at least crash and report some sort of information and help me realize where I'd gone wrong.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

React 16.3.0

Chrome 65.0.3325.181