How to import an external React component to Asp.Net

Asked

Viewed 138 times

1

Hello, I wanted to import a webpack generated React external component (Bundle.js) into my Asp.net MVC application. I am trying to import the "Bundle.js" file to my page and process the React component in the Babel script tag, but nothing happens. What is the correct way to import an external component from a webpack library into a View?

Here’s an example of how I’m doing, "Customtextbox" is the component I want to use that’s inside Bundle.js:

<script src="~/Scripts/bundle.js"></script>

<script type="text/babel">

    ReactDOM.render(
    <CustomTextbox />,
        document.getElementById('timer')
    );
</script>
  • 1

    Put this script ReactDOM.render( inside the component for the webpack to pack everything. Otherwise you have to export Reactdom to global space and the components that are in that `Bundle.js``

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.