Skip to content

Commit

Permalink
react basic added
Browse files Browse the repository at this point in the history
  • Loading branch information
pritam1bnk committed Aug 26, 2022
1 parent 3a0412a commit 0725f59
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 16 deletions.
53 changes: 37 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
import React from 'react';
import { useState } from 'react';
import logo from './logo.svg';
import './App.css';
import Student from './Student';

function App() {
const [data, setData] = useState(null)
const [print, setPrint] = useState(false)
function getData(val){
console.log(val.target.value);
setData(val.target.value)
}

console.log("-------------")
// return (
// <div className="App">
// <h1>{data}</h1>
// <button onClick={updateData}>Update Data</button>
// </div>

// );
// return (
// <div className="App">
// <h1>Props in React</h1>
// <Student name={name} email="[email protected]" other={{address:"delhi",mobile:"000"}} />
// <Student name="Peter" email="[email protected]" other={{address:"delhi1",mobile:"001"}}/>
// <Student name="John" email="[email protected]" other={{address:"delhi2",mobile:"002"}}/>
// <button onClick={()=>{setData("Manish")}}>Update Details</button>
// </div>
// );
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div className='App'>
{
print?
<h1>{data}</h1>
:null
}
<h1>{data}</h1>
<input type="text" onChange={getData}></input>
<button onClick={()=>setPrint(true)}>Print Data</button>
</div>
);
)
}

export default App;
13 changes: 13 additions & 0 deletions src/Student.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Student(props) {
console.log(props);
return (
<div style={{ backgroundColor: "skyblue" }}>
<h1>Hello {props.name}</h1>
<h2>Email : {props.email}</h2>
<h3>Address : {props.other.address}</h3>
<h4>Mobile : {props.other.mobile}</h4>
</div>
)
}

export default Student;
9 changes: 9 additions & 0 deletions src/Users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Users() {
return (
<div className="App">
<h1>Hello Users</h1>
</div>
);
}

export default Users;
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import Users from './Users';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
<Users />
</React.StrictMode>
);

Expand Down

0 comments on commit 0725f59

Please sign in to comment.