Skip to content

Commit

Permalink
fix: add object arrays (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon authored Mar 8, 2024
1 parent 28610ac commit be040b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/use-replicant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { klona as clone } from "klona/json";

type JsonValue = boolean | number | string | null;

type Json = JsonValue | JsonValue[] | { [key: string]: Json };
type Json = JsonValue | JsonValue[] | { [key: string]: Json } | Json[];

export type UseReplicantOptions<T> = {
defaultValue?: T;
Expand Down
8 changes: 7 additions & 1 deletion tests/use-replicant.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ interface RunnerNameProps {
prefix?: string;
}

type RunnerNameReplicant = {
runner: {
name: string;
};
};

const RunnerName: React.FC<RunnerNameProps> = (props) => {
const { prefix } = props;
const repName = `${prefix ?? "default"}:currentRun`;
const [currentRun] = useReplicant(repName, {
const [currentRun] = useReplicant<RunnerNameReplicant>(repName, {
defaultValue: { runner: { name: "foo" } },
});
if (!currentRun) {
Expand Down

0 comments on commit be040b3

Please sign in to comment.