Reac component is not beeing exported - reactjs

I'm new to react and I'm just trying to start a new website but not being successful at it. For some reason, I get this error Module not found: Can't resolve './pages' in '/Users/joanaleitaooliveira/repos/web-project/src'. Here you can see the App.js file and the about page file. All the other pages are the same.
I've also tried ./src/pages/About/index.jsx but got the same result. Can anyone tell me why is this happening?
[![enter image description here][1]][1]

The cause of the problem is due to the path mentioned in import statement not getting resolved.
Problem can be fixed by using the complete path to the component in the import statement.
Working example:
import Home from "./pages/Home"
import About from "./pages/About"
import Contact from "./pages/Contact"

You would need to create an index.js file in pages that exports all these components if you want to import through ./pages.

Related

Module not found: Can't resolve './AppAPI' in project folder

I have done everything right when setting up my react app and for some reason I'm getting this error.
All my code is in a .js file called App.API.js which is located in the src folder.
The error is coming from the index.js which has the code: import App from './AppAPI';
I've gone through several guides and other posts with similar questions but no solution is working. I have created a whole new react app and tried again but have had no luck.
change :
import App from './AppAPI'
to :
import App from "./App.API";

Directly import relative imports by # in a shorthand syntax in expo or react native projects

I have seen this youtube video refrence.
I am trying to import screens by using this
import FirstScreen from "#screens/FirstScreen";
import SecondScreen from "#screens/SecondScreen";
and making a package.json file in screens folder and writing this code in it.
Thanks for helping.
{
"name": "#screens"
}
Is there a way to do that or I am doing it wrong as I am getting this error.
Error --
enter image description here

SyntaxError: Cannot use import statement outside a module React JS Antd

For bundle size optimization instead of getting components from the lib folder, I am importing it from the es folder.
Example:
import Modal from 'antd/es/modal';
So on writing test cases it is giving me the following error
SyntaxError: Cannot use import statement outside a module
I have gone through related questions possibly duplicate but couldn't resolve it with my current implementation as it does not fall to global scope.
So my question is, Is there any way to achieve this
I tried referring to the following links too but no help,
https://github.com/reactstrap/reactstrap/blob/master/package.json#L21
https://medium.com/#fredriccliver/syntaxerror-cannot-use-import-statement-outside-a-module-69182014b8c6
Change
import frFR from 'antd/es/locale/fr_FR';
to
import frFR from 'antd/lib/locale/fr_FR';
fix this problem.

React Failed to compile. Module not found: Can't resolve 'Main.css'

To my React project I added "Main.css" file and I imported it in Navigation.js component. Unfortunately, I get this error "Failed to compile. ./src/components/Navigation.js
Module not found: Can't resolve 'Main.css' in '/Users/monikastrzalka/Documents/INFORMATYKA/WEB DEVELOPMENT PROJECTS/PROJECT2/project2/src/components'". I have no idea why this is happening.That's the first time. Please help me. Below you will find necessary data.
enter image description here
I believe your issue lies in the import
import "./Main.css"
There's a few different ways import trys to find what you're indicating. Currently import is interpreting 'Main.css' as a full package - if there was a 'Main.css' library in your package.json and living in your node_modules folder import would be handling this correctly.
The other way to import is to identify a relative filepath. You can indicate the relative path the same way as your terminal.
If you try:
import "./Main.css"
import will know to look for a relative file pathway that exists inside your project.

React - native .I can't import images, says it's not present on the way

When I try to import any file other than .js extension, it gives error saying I can't find the file. I'm trying to import an image right now. Auto complete does not find the image, but finds the folder. If I type the name of the image manually it gives error when making the bundle.
version react-native 0.60.
enter image description here
If you want to use it like that you can add an index.js file inside of your image folder to export all your images, like this:
images/index.js
import login from './ImageLogin.jpg';
export default { login };
login.js
import images from '../images';
and then
<Image source={images.login}/>

Resources