5

I am a beginner on ReactNative, I am creating a Twitter clone to practice.

I had already developed a first application and I had no problem.

But since I started the new project, after adding custom modules in the project I have this error message.

In this case I want to import a style sheet into my custom Tweet component, I added a capture, it's better for you.

Screenshot - error message

So, I followed all the instructions of the capture, except Watchmen because I'm working on Windows 10, after doing the procedure, I recreated a new project with "react-create-app", restart XDE expo and the application but the problem comes back ...

I also tried the Github procedure dealing with the problem (see the catch for the issue) here => https://github.com/facebook/react-native/issues/4968

FoxaLiveJS
  • 243
  • 3
  • 7
  • 14
  • Can you add the code you're using to import the module, and the declaration/export of the module? – sanjar Jun 13 '18 at 18:47

4 Answers4

1

Simply follow again below steps

yarn add react-native-tweet-view
react-native link react-native-tweet-view
Rajesh N
  • 6,198
  • 2
  • 47
  • 58
0

There is 3 issue in your import :

  1. You must not write the extension of the module you're importing
  2. Your file is named "Tweet.style" and you try to import "Tweet.styles"
  3. You have to import the relative path of your module

Correct import should be :

import styles from './Tweet.style'
sanjar
  • 1,081
  • 2
  • 9
  • 15
  • Really sorry, I made a mistake in the post, the file is well named in Tweet.styles.js in my project – FoxaLiveJS Jun 13 '18 at 19:44
  • Ok, so just remove the ".js" at the end of the import. – sanjar Jun 13 '18 at 19:51
  • I just tried removing the .js, the problem is still there. – FoxaLiveJS Jun 13 '18 at 19:55
  • 1
    Ok my bad, you have to provide a relative path ('./Tweet.style'), I'll update my answer – sanjar Jun 13 '18 at 21:28
  • I added './' to the relative path and it worked, thank you very much! By cons I often make this mistake, there is not a trick to improve this? I think you have to have a good project structure, but which one? You do not need code in App.js, but only import custom components into App.js, is it? – FoxaLiveJS Jun 15 '18 at 19:42
0

check the top of your file so that you have not imported

import { threadId } from 'worker_threads';

I removed that and it worked

Cyrus Zei
  • 2,589
  • 1
  • 27
  • 37
0

Some time this error happens because of malformed JS styles .. like

backgroundColor= '#fff'

instead of backgroundColor: '#fff' this ..

Wahab Khan Jadon
  • 875
  • 13
  • 21