Importing React Native component - reactjs

I know there are several questions about this, but I can't seem to find any that solves my issue, then I ask, why isn't this working?
I've tried:
import Row from '../Row';
import Row from './src/components/Row';
import Row from 'Row';
import Row from '../../components/Row';
So, here is my project file structure:
src
components
MainList
Row
screens
etc.
So I'm trying to import Row into MainList.js, without any success, the error which changes with each path I enter on the import goes:
Unable to resolve "../Row" from "src\components\MainList.js"
Thank you very much.
PS: I should clarify I'm exporting Row with
export default Row;

MainList.js is staying at the same directory with Row.js. Hence the correct syntax should be:
import Row from './Row';
Since I noticed that you're trial and error, just a side note:
.. means going back one level from the directory of your current file.
./ is referring to the same directory

Your file is in the same directory you can import like this :
import Row from './Row'

Related

Dynamically import images in ReactJS with variables

I'm creating a game with sprays but I can't put all the sprays in the same folder because at least 50/ 100 and more are comming and I want to import all the images from a folder, the problem is that the name is variable.
Example :
import * as JhonImgs from "../images/Jhon/"
import * as JhonImgs from "../images/Lucas/"
Or something like that. All the images have the same extension, .png.
The problem is require.context() doesn't allow me use variables. And I can't call one by one, or use a cdn server.
Thanks.

Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react' error with React import correct

I am getting the below error on a page that is stopping it being rendered and after checking other similar errors I have double checked the import is correct and the node_modules react index file is installed.
What else could be causing this? I have had linting issues yesterday out of nowhere that I thought had fixed themselves.
The file this refers to should be node_modules/React/react.indexjs but on my system is node_modules/react.index.js. I haven't changed this myself so i'm not sure where it has come from. I have also removed any code that was added to this file which could of been causing it.
Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react'
This happens when you import react like this
import React from "React"
notice the capital R
instead, you should do :
import React from "react"
( with a small r )
This happens due to case sensitivity. Check if the file name is exactly the same in the same case.
Eg:
Cannot find file: 'CheckBox.js'
Check if the filename is exactly CheckBox.js not Checkbox.js
try creating the index.js in the src folder, i'm sure you created it outside the src folder.

Importing a non-image file in ReactJS is not working

I have an ICM profile that I wish to import into a certain file. I need this because I need to fetch the contents of the file into a Uint8Array (array buffer). However, I can't get the file to import.
I've tried
import file from './tester.icm';
import { file } from './tester.icm';
const file = require('./tester.icm');
I would expect it to work like importing an image:
import logo from './logo.png';
However, this approach does not work.
This is a new question since it deals with a binary format, not a simple text file.
The import statement that you are using is done by Webpack and not by React. Webpack can not import all file types by default, for some file types you will need to configure your own loader. You can have a look at the docs for more information.

How to import component correctly?

This is maybe stupid question, but I am new and this problem took me a couple of hours :/. I am trying to import component like this:
import * as test from "../../../../common/containers/sidebar/Sidebar";
and file where I write this line is located in :
src/pages/example/containers/example.
above path of 'Sidebar' is correct but react gives me 'Sidebar' is not defined.
I found some kind of similar questions but it didn't help me so please if anyone has anny suggestions write below, huge thanks! and one more thing is this correct way to import files like this - I mean '../../../../' <- this looks like little weird for me.
You can add rootDir option to your jest config. And then just import components as from the global path.
For example if root is your src folder. Just import pages/example/containers/example

WinForms - change name of form file name

I have a project that I've been working on, and I need to import an existing form that someone else has created. The file name of the form I need to import is Form2.vb. However, there is already a Form2.vb in my current project. How do I add the other Form2.vb file in VS without replacing the Form2.vb that's already in my project?
Don't leave your files with the default name like FormN.vb. Rename the existing file to match its function. Once you do that, you could import the other form without a naming conflict. Once you import it, give it a good name that matches its function.

Resources