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();
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