如何更新状态数组中的单个元素?下面是我的问题的一个示例:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
点击渲染按钮后,我收到const Cars = props => {
const [cars,setCars] = React.useState(["Honda","Toyota","Dodge"])
const handleclick1 = () => { setCars[0]("Jeep") }
const handleclick2 = () => { setCars[1]("Jeep") }
const handleclick3 = () => { setCars[2]("Jeep") }
return (
<div>
<button onClick={handleclick1}>{cars[0]}</button>
<button onClick={handleclick2}>{cars[1]}</button>
<button onClick={handleclick3}>{cars[2]}</button>
</div>
)
};
。我知道如何在React类中执行此操作,但是如何在React Hook中执行此操作?