0

My React app is bundled with Webpack and I would like to import my component constructor to the console for debugging. If this is possible what is the syntax for importing modules to the console.

lcharbon
  • 3,030
  • 2
  • 16
  • 18

1 Answers1

1

Can't see why you would need that, but you could do something like this:

window.testing_one = (params) => {
  ReactDOM.render(
    <App {...params} />,
    document.getElementById('root')
  );
};

Then you can manually call testing_one({some: 'params'}); in console.

Better way would be do the testing in test environment where you can do the same thing easier. See something like: https://medium.com/selleo/testing-react-components-best-practices-2f77ac302d12

Hardy
  • 5,590
  • 2
  • 18
  • 27