1

Hi I have gone through some answers but none of them seem to work. I have a Javascript file like so. It is stored in my src folder.

let model = function() {

    let model = function(data) {
        if (!data) return;
        return map.call(this, data);
    };

    function map(data) {
        return data;
    }

    model.map = function(_) {
        if (!arguments.length) return map;
        map = _;
        return model;
    };

    return model;

};

In one of my components, I am trying to use this file.

import model from '../models/GraphModel';

And then I am trying to use it.

var graph = model();
console.log(graph);

But nothing seems to output and I cant seem to set anything. How can I use this Javascript in my components?

Thanks

1 Answer 1

4

I think it's because you didn't export model.

Try adding export before let: export let model.

And import it as such: import { model } from '../models/GraphModel';

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

Comments

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.