1

I would like to use the following react component ImageLoader but i dont understand how to integrate it into my current Asp.net mvc project. I m currently running my own reactJs components from a separate JSX using the help of ReactJs.net.

4
  • Are you asking for a React project or a React Native project? Commented Dec 2, 2015 at 1:52
  • i am asking for a walk through on how to use someone else's reusable react component from my jsx file. Commented Dec 2, 2015 at 17:42
  • 1
    Ok I'm asking because that module is specific for react web and won't work with react native Commented Dec 2, 2015 at 18:13
  • react native is for mobile correct? I m not using react native. I am using react in my Asp.net Mvc project. Commented Dec 3, 2015 at 16:56

1 Answer 1

1

You can do it, but it's not a trivial task, because that component is developed using ES6, or, you could say, a new definition for Javascript (or more exactly, "ECMAscript"). You have two main options:

1) Develop the component yourself. You can access the source code of the component in its Github Page. Even if you are not familiar with ES6, I think the logic behind this component should be easy to figure (I recommend this if you don't want to dig on precompiling and using Npm/Bower/etc).

2) As ES6 is not supported by all browsers at this time (Dec 23, 2015). To make it work properly with your project in Visual Studio, you will need to configure your project to use NPM and GULP and BABEL (look up at the first link for more info) to "pre-compile" the file and be able to use it in your JSX. Using Bower or Npm you should be able to import that component into your project.

You could also copy and paste the code inside a file in your project a look up to precompile it with Babel for MSBuild.

Either way, you are going to need to be more aware about ES6 and/or precopiling javascript files in Visual Studio.

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

3 Comments

Do you have a simple visual studio project with this set? Luckily I still have been able to code the needed components myself, but I would rather get to the point of reusing other components. This would make for a perfect pluralsight video!
here is a great example of integrating reactjs with Asp.net MVC msdn.microsoft.com/magazine/0216magcode
Also check out the associated article in MSDN magazine by Graham Mendick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.