Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

hello my Seniors. i am new in the rect vite, i was exercising my self then met with this error while running.


import { useState } from 'react'
import './App.css'
import React from 'react'
import { Text, Button } from 'react-native'

function App() {
const [counter, setCounter] = React.useState(0)
// // let counter = 15
// const addValue = () => {
// setCounter = (counter + 1)
// }
// const removeValue = () =>{
// setCounter = (counter - 1);
// }

return (
<>
<h1>React course with Julien {counter}</h1>
<h2>counter value: {counter} </h2>
<button onPress={() => { setCounter(counter + 1 ) }} title = "Increment">Add value</button> {" "}
<button onPress={() => { setCounter(counter - 1 ) }} title="Decrement">Remove value</button>
<p>Footer: {counter} </p>
</>
)
}

export default App





and this is the output in the browser.


plugin:vite:import-analysis] Failed to resolve import "react-native" from "src\App.jsx". Does the file exist?
C:/xampp/htdocs/react_git/react-vite02/src/App.jsx:4:29
19 | import "./App.css";
20 | import React from "react";
21 | import { Text, Button } from "react-native";
| ^
22 | function App() {
23 | _s();


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


The error you are encountering, "Failed to resolve import 'react-native' from 'src\App.jsx'," suggests that the "react-native" module cannot be resolved in your "src\App.jsx" file. To resolve this issue, you can follow a few steps:

Make sure you have added the "react-native" module to your project. You can do this by navigating to the directory of your project in the terminal or command prompt and running the following command:

npm install react-native

If the issue persists, ensure that the "react-native" module is present in the "node_modules" folder. If it's missing, you can run the following command in the terminal or command prompt to reinstall all dependencies:

npm install

Try restarting your project:

npm start

If the problem persists after these steps, check your project's dependencies and configuration files. Missing specific files or dependencies can lead to such errors.



thanks for your response sir, ended, i tried with another method, cause i was hurry up to advance


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(