mirror of
https://github.com/logos-messaging/waku-react.git
synced 2026-01-15 20:43:10 +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": "^7.32.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.0",
|
||||||
"jest": "^29.4.3",
|
"jest": "^29.4.3",
|
||||||
"jest-environment-jsdom": "^29.4.3",
|
"jest-environment-jsdom": "^29.4.3",
|
||||||
"jest-watch-typeahead": "^2.2.2",
|
"jest-watch-typeahead": "^2.2.2",
|
||||||
|
|||||||
@ -17,9 +17,9 @@ import {
|
|||||||
type WakuContextType<T extends Waku> = CrateWakuHook<T>;
|
type WakuContextType<T extends Waku> = CrateWakuHook<T>;
|
||||||
|
|
||||||
export const WakuContext = React.createContext<WakuContextType<Waku>>({
|
export const WakuContext = React.createContext<WakuContextType<Waku>>({
|
||||||
node: null,
|
node: undefined,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
error: null,
|
error: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import type { Protocols, Waku } from "@waku/interfaces";
|
|||||||
|
|
||||||
export type HookState = {
|
export type HookState = {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
error: null | string;
|
error: undefined | string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CrateWakuHook<T extends Waku> = HookState & {
|
export type CrateWakuHook<T extends Waku> = HookState & {
|
||||||
node: null | T;
|
node: undefined | T;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BootstrapNodeOptions<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";
|
import type { Decoder, Encoder } from "@waku/core/dist/lib/message/version_0";
|
||||||
|
|
||||||
type ContentPair = {
|
type ContentPair = {
|
||||||
encoder: null | Encoder;
|
encoder: undefined | Encoder;
|
||||||
decoder: null | Decoder;
|
decoder: undefined | Decoder;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,8 +17,8 @@ export const useContentPair = (
|
|||||||
contentTopic: string,
|
contentTopic: string,
|
||||||
ephemeral?: boolean,
|
ephemeral?: boolean,
|
||||||
): ContentPair => {
|
): ContentPair => {
|
||||||
const [encoder, setEncoder] = React.useState<null | Encoder>(null);
|
const [encoder, setEncoder] = React.useState<undefined | Encoder>();
|
||||||
const [decoder, setDecoder] = React.useState<null | Decoder>(null);
|
const [decoder, setDecoder] = React.useState<undefined | Decoder>();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setEncoder(createEncoder(contentTopic, ephemeral));
|
setEncoder(createEncoder(contentTopic, ephemeral));
|
||||||
|
|||||||
@ -22,9 +22,9 @@ const useCreateNode = <N extends Waku, T = {}>(
|
|||||||
): CrateWakuHook<N> => {
|
): CrateWakuHook<N> => {
|
||||||
const { factory, options, protocols = [] } = params;
|
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 [isLoading, setLoading] = React.useState<boolean>(true);
|
||||||
const [error, setError] = React.useState<null | string>(null);
|
const [error, setError] = React.useState<undefined | string>(undefined);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export const useFilterSubscribe = (
|
|||||||
): UseFilterSubscribeResult => {
|
): UseFilterSubscribeResult => {
|
||||||
const { waku, decoder } = params;
|
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 [isLoading, setLoading] = React.useState<boolean>(false);
|
||||||
const [messages, setMessage] = React.useState<IDecodedMessage[]>([]);
|
const [messages, setMessage] = React.useState<IDecodedMessage[]>([]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user