Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(kitchen-sink): update dependencies and fix a key issue in the todo list #136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
},
"dependencies": {
"@vercel/analytics": "^1.4.0",
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
"react": "19.0.0-rc.1",
"react-dom": "19.0.0-rc.1",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-scan": "^0.0.34",
"sugar-high": "^0.7.5",
"vite-plugin-inspect": "^0.8.7"
"sugar-high": "^0.7.5"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"vite": "^5.4.3"
"vite": "^5.4.3",
"vite-plugin-inspect": "^0.8.7"
}
}
37 changes: 21 additions & 16 deletions packages/kitchen-sink/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ export const App = () => {

<div className="task-section">
<AddTaskBar
onCreate={(value) => {
if (!value) return;
setTasks([...tasks, value]);
onCreate={(task) => {
if (!task) return;
setTasks([...tasks, task]);
}}
/>
<TaskList
tasks={tasks}
onDelete={(value) =>
setTasks(tasks.filter((task) => task !== value))
}
onDelete={(task) => {
setTasks(tasks.filter((t) => t.id !== task.id));
}}
/>
</div>
</div>
Expand All @@ -60,7 +60,7 @@ export const TaskList = ({ tasks, onDelete }) => {
return (
<ul>
{tasks.map((task) => (
<TaskItem key={task} task={task} onDelete={onDelete} />
<TaskItem key={task.id} task={task} onDelete={onDelete} />
))}
</ul>
);
Expand All @@ -70,7 +70,7 @@ export const TaskItem = ({ task, onDelete }) => {
const { tooltip } = React.useContext(TooltipContext);
return (
<li className="task-item" tooltip={tooltip}>
{task}
{task.text}
<Button onClick={() => onDelete(task)}>Delete</Button>
</li>
);
Expand All @@ -82,7 +82,7 @@ export const Text = ({ children }) => {

export const Button = ({ onClick, children }) => {
return (
<button onClick={onClick}>
<button type="button" onClick={onClick}>
<Text>{children}</Text>
</button>
);
Expand All @@ -91,21 +91,26 @@ export const Button = ({ onClick, children }) => {
export const AddTaskBar = ({ onCreate }) => {
const [value, setValue] = useState('');
const [id, setId] = useState(0);

const handleCreate = () => {
if (value.length === 0) return;
onCreate({ id, text: `${value} (${id})` });
setValue('');
setId(id + 1);
};

return (
<div className="add-task-container">
<Input
onChange={(value) => setValue(value)}
onEnter={(value) => {
onCreate(`${value} (${id})`);
setValue('');
setId(id + 1);
onEnter={() => {
handleCreate();
}}
value={value}
/>
<Button
onClick={() => {
onCreate(value);
setValue('');
handleCreate();
}}
>
Add Task
Expand All @@ -123,7 +128,7 @@ export const Input = ({ onChange, onEnter, value }) => {
onChange={(e) => onChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
onEnter(e.target.value);
onEnter();
}
}}
value={value}
Expand Down
6 changes: 1 addition & 5 deletions packages/kitchen-sink/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import Inspect from 'vite-plugin-inspect';

export default defineConfig({
plugins: [
react({
// babel: {
// plugins: [['babel-plugin-react-compiler', {}]],
// },
}),
react({}),
Inspect(),
],
resolve:
Expand Down
114 changes: 102 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.