how to use props in functional component in react
import React, { useState } from 'react';
import './App.css';
import Todo from './components/Todo'
function App() {
const [todos, setTodos] = useState([
{
id: 1,
title: 'This is first list'
},
{
id: 2,
title: 'This is second list'
},
{
id: 3,
title: 'This is third list'
},
]);
return (
<div className="App">
<h1></h1>
<Todo todos={todos}/> //This is how i'm passing props in parent component
</div>
);
}
export default App;
class Welcome extends React.Component {
render() {
return <h1>Bonjour, {this.props.name}</h1>;
}
}function Comment(props) {
return (
<div className="Comment">
<div className="UserInfo">
<img className="Avatar"
src={props.author.avatarUrl}
alt={props.author.name}
/>
<div className="UserInfo-name">
{props.author.name}
</div>
</div>
<div className="Comment-text">
{props.text}
</div>
<div className="Comment-date">
{formatDate(props.date)}
</div>
</div>
);
}
Also in JavaScript:
- convert js to python online
- timestamp js
- link stylesheet in javascript
- js stop form submit
- regex optional whitespace characters
- denuncia perturbação
- replacing characters in string javascript
- how remove child in jquery
- load js
- how to scroll to an element javascript react
- display form input on console jquery
- set class name javascript
- javascript convert Object.entries back to object
- function inside function javascript
- js create a promise
- jquery selected option
- node.js mysql wildcard
- check first two number jquery
- import a script to my react componetn
- javascript write to file and download
- package json proxy
- check if word is in string javascript
- discord.js ticket system stackoverflow
- js get element by X Y