use undefined instead on null

This commit is contained in:
Sasha 2023-02-21 21:27:23 +01:00
parent 3bb5f6342d
commit 2f2d113805
No known key found for this signature in database
6 changed files with 12 additions and 12 deletions

2
package-lock.json generated
View File

@ -29,7 +29,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"husky": "^8.0.0",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"jest-watch-typeahead": "^2.2.2",

View File

@ -17,9 +17,9 @@ import {
type WakuContextType<T extends Waku> = CrateWakuHook<T>;
export const WakuContext = React.createContext<WakuContextType<Waku>>({
node: null,
node: undefined,
isLoading: false,
error: null,
error: undefined,
});
/**

View File

@ -4,11 +4,11 @@ import type { Protocols, Waku } from "@waku/interfaces";
export type HookState = {
isLoading: boolean;
error: null | string;
error: undefined | string;
};
export type CrateWakuHook<T extends Waku> = HookState & {
node: null | T;
node: undefined | T;
};
export type BootstrapNodeOptions<T = {}> = {

View File

@ -3,8 +3,8 @@ import { createDecoder, createEncoder } from "@waku/core";
import type { Decoder, Encoder } from "@waku/core/dist/lib/message/version_0";
type ContentPair = {
encoder: null | Encoder;
decoder: null | Decoder;
encoder: undefined | Encoder;
decoder: undefined | Decoder;
};
/**
@ -17,8 +17,8 @@ export const useContentPair = (
contentTopic: string,
ephemeral?: boolean,
): ContentPair => {
const [encoder, setEncoder] = React.useState<null | Encoder>(null);
const [decoder, setDecoder] = React.useState<null | Decoder>(null);
const [encoder, setEncoder] = React.useState<undefined | Encoder>();
const [decoder, setDecoder] = React.useState<undefined | Decoder>();
React.useEffect(() => {
setEncoder(createEncoder(contentTopic, ephemeral));

View File

@ -22,9 +22,9 @@ const useCreateNode = <N extends Waku, T = {}>(
): CrateWakuHook<N> => {
const { factory, options, protocols = [] } = params;
const [node, setNode] = React.useState<N | null>(null);
const [node, setNode] = React.useState<N | undefined>(undefined);
const [isLoading, setLoading] = React.useState<boolean>(true);
const [error, setError] = React.useState<null | string>(null);
const [error, setError] = React.useState<undefined | string>(undefined);
React.useEffect(() => {
let cancelled = false;

View File

@ -17,7 +17,7 @@ export const useFilterSubscribe = (
): UseFilterSubscribeResult => {
const { waku, decoder } = params;
const [error, setError] = React.useState<null | string>(null);
const [error, setError] = React.useState<undefined | string>(undefined);
const [isLoading, setLoading] = React.useState<boolean>(false);
const [messages, setMessage] = React.useState<IDecodedMessage[]>([]);