20 lines
372 B
TypeScript
20 lines
372 B
TypeScript
import React, { useEffect, useState } from 'react';
|
|
|
|
const App = ({ initialState }) => {
|
|
const [name, setName] = useState(initialState.name);
|
|
useEffect(() => {
|
|
setName('Client'); // 仅客户端执行
|
|
}, []);
|
|
return (
|
|
<div
|
|
onClick={() => {
|
|
setName('Jane Doe233');
|
|
}}
|
|
>
|
|
Hello World {name}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default App;
|