mirror of
https://github.com/logos-messaging/waku-react.git
synced 2026-01-09 17:43:11 +00:00
use undefined instead on null
This commit is contained in:
parent
3bb5f6342d
commit
2f2d113805
2
package-lock.json
generated
2
package-lock.json
generated
@ -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",
|
||||
|
||||
@ -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,
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -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 = {}> = {
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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[]>([]);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user