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.

0

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your response but I needed a way to do this at run time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.