Skip to content

Commit

Permalink
Deepsourcce: Fix performance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Apr 19, 2024
1 parent 3233301 commit 172d81d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions lib/r18gs/tests/use-rgs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { describe, test } from "vitest";
import { act, fireEvent, render, screen } from "@testing-library/react";
import useRGS from "../src";
import { ChangeEvent, useCallback } from "react";

function Component1() {
const [count, setCount] = useRGS<number>("count", 0);
const handleChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setCount(parseInt(e.target.value));
},
[setCount],
);
return (
<div>
<input
data-testid="input"
onChange={e => {
setCount(parseInt(e.target.value));
}}
type="number"
value={count}
/>
<input data-testid="input" onChange={handleChange} type="number" value={count} />
</div>
);
}
Expand Down
15 changes: 8 additions & 7 deletions packages/shared-ui/src/root/counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import useRGS from "r18gs";
import { COUNTER } from "../constants/global-states";
import { ChangeEvent, useCallback } from "react";

export default function Counter() {
const [count, setCount] = useRGS(COUNTER, 0);
const handleChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
setCount(parseInt(e.target.value));
},
[setCount],
);
return (
<div>
<h2>Clinet component 1</h2>
<input
onChange={e => {
setCount(parseInt(e.target.value.trim()));
}}
type="number"
value={count}
/>
<input onChange={handleChange} type="number" value={count} />
</div>
);
}

0 comments on commit 172d81d

Please sign in to comment.