2

I am working on a website and tried to include a ReactJS component and I'm doing it like so:

import React from "react";
import ReactDOM from "react-dom";
import Layout from "Layout.jsx";

const app = angular.module('myApp');

const reactDirective = app.directive('reactDirective', function() {

  return {
      template: '<div id="reactapp"></div>',
      link: function(scope, el, attrs){
          ReactDOM.render(<Layout/>, document.getElementById('reactapp'));
        }
    }
});

and the Layout.jsx

import React from 'react';
export default class Layout extends React.Component {
    constructor(props){
      super(props);
    }
    render() {
        return (
            <div>
                This is ReactJS
            </div>
        );
   }
}

However whenever it compiles, it gives me
ERROR in ./react-app.js Module not found: Error: Cannot resolve module 'layout.jsx'
Can anyone tell me what's wrong with my code?

1 Answer 1

1

Imports of local files that don't live in node_modules have to be relative paths.

import Layout from "./Layout.jsx";
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.