/**
 * Use this when profiling React to add a button to the page that will stop profiling and 
 * print the wasted time/renders to the console when clicked.
 * The button will remove itself when done.
 */
(function() {
    // Create a button :-)
    const stopButton = document.createElement('button');
    stopButton.textContent = 'Perf.stop()';
    stopButton.style.cssText = `
        position: fixed;
        top: 0; 
        left: 0;
        padding: 10px;
        opacity: 0.5;
    `;

    // Stop React Perf profiling and print wasted time/renders
    // Then remove the event handler and the button
    stopButton.addEventListener('click', () => {
        React.addons.Perf.stop();
        React.addons.Perf.printWasted()
        stopButton.removeEventListener('click', stopButton);
        document.body.removeChild(stopButton);
    });

	// Add the button to the DOM and start React Perf
    document.body.appendChild(stopButton);
    React.addons.Perf.start();
}());