Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • 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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(