Jayson De los Reyes Jayson De los Reyes - 7 months ago 17
Javascript Question

How to import js file from other js file

I'm trying to import TodoItem.jsx to TodoList_spec.jsx.

Here's my project directory structure.

- TodoMVCTuts
- app
- bootstrap
- config
- database
- node_modules
- public
- resources
- assets
- js
- components
- TodoItem.jsx
- storage
- tests
- js
- components
- TodoList_spec.jsx
- vendor


Here's my code:

// /tests/js/components/TodoList_spec.jsx
import React from 'react';
import TestUtils from 'react-addons-test-utils';
// ** Import TodoItem.jsx **
//import TodoItem from '../resources/assets/js/components/TodoItem';
import { expect } from 'chai';
import { List, Map } from 'immutable';
**


How can I achieve that? Thanks in advance.

QoP QoP
Answer

This should work

import TodoItem from  '../../../resources/assets/js/components/TodoItem';