mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 04:59:02 +08:00
26 lines
574 B
JavaScript
26 lines
574 B
JavaScript
import { createSignal } from "solid-js";
|
|
|
|
import { UserContext } from "./UserContext";
|
|
import UserProfile from "./UserProfile";
|
|
|
|
export default function App() {
|
|
const [user, setUser] = createSignal({
|
|
id: 1,
|
|
username: "unicorn42",
|
|
email: "unicorn42@example.com",
|
|
});
|
|
|
|
function updateUsername(newUsername) {
|
|
setUser({ ...user(), username: newUsername });
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<h1>Welcome back, {user().username}</h1>
|
|
<UserContext.Provider value={[user, updateUsername]}>
|
|
<UserProfile />
|
|
</UserContext.Provider>
|
|
</>
|
|
);
|
|
}
|