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.
Asked
Active
Viewed 203 times
1 Answers
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
-
Thank you for your response but I needed a way to do this at run time. – lcharbon Aug 06 '17 at 16:31