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.
1 Answer
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
1 Comment
lcharbon
Thank you for your response but I needed a way to do this at run time.