3

I'm working on the react project. I created project with create-react-app. I need to import 'js-sequence-diagram' javascript file in my component. How can I import javascript min file in my component?

what I want to do is: https://github.com/zfanta/react-sequence-diagram

where "index.js" file "sequence-diagram-2.0.1.js" file was used. But I could not use it like that.

4
  • 1
    Please clarify your question and tell us what code you used, what behavior you are seeing as a result, and how it differs from what what you are expecting. Contributors seem to be having a hard time guessing about how to help. Commented Apr 9, 2019 at 9:41
  • I just want to import 'sequence-diagram-2.0.1.js' in local. Commented Apr 9, 2019 at 11:34
  • I need to use Diagram. Commented Apr 15, 2019 at 5:56
  • The below responses answered your literal question "How can I import javascript min file in my component?". From your comments below, it sounds like you have tried import Diagram from './sequence-diagram-2.0.1' somewhere in your code, and that you are confident you have the correct file paths and access to the library. It would be helpful if this information were included in your question, but the most helpful thing would be enough code to provide a "minimal, complete, and verifiable example" (stackoverflow.com/help/mcve) of the problem you are experiencing so we can answer usefully. Commented Apr 15, 2019 at 7:43

2 Answers 2

3

1- install it first using

npm install react-sequence-diagram

2- then just put import SequenceDiagram from 'react-sequence-diagram; where ever you want to use the component

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

3 Comments

I can already use the library.That's not the problem.Just like here, I want to import sequence-diagram-2.0.1.js in SequenceDiagram component. Because there are some shortcomings in this library. So I want to write from the beginning. Like this :import Diagram from './sequence-diagram-2.0.1'; in github.com/zfanta/react-sequence-diagram/blob/master/src/…
if you mean './sequence-diagram-2.0.1 this is just the directory where your component is, so just copy the js file to the same directory of you component
I did them, but when I import it, I get an error. There are no problems in the file path.
-1

Can you plz try this once,

import * as Diagram from './sequence-diagram-2.0.1'

1 Comment

plz try this import 'sequence-diagram-2.0.1'

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.