mirror of
https://github.com/logos-messaging/waku-react.git
synced 2026-01-08 09:03:09 +00:00
use React global var
This commit is contained in:
parent
bd3bfb8134
commit
3bb5f6342d
@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import React from "react";
|
||||
import { createDecoder, createEncoder } from "@waku/core";
|
||||
import type { Decoder, Encoder } from "@waku/core/dist/lib/message/version_0";
|
||||
|
||||
@ -17,10 +17,10 @@ export const useContentPair = (
|
||||
contentTopic: string,
|
||||
ephemeral?: boolean,
|
||||
): ContentPair => {
|
||||
const [encoder, setEncoder] = useState<null | Encoder>(null);
|
||||
const [decoder, setDecoder] = useState<null | Decoder>(null);
|
||||
const [encoder, setEncoder] = React.useState<null | Encoder>(null);
|
||||
const [decoder, setDecoder] = React.useState<null | Decoder>(null);
|
||||
|
||||
useEffect(() => {
|
||||
React.useEffect(() => {
|
||||
setEncoder(createEncoder(contentTopic, ephemeral));
|
||||
setDecoder(createDecoder(contentTopic));
|
||||
}, [contentTopic, ephemeral]);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import React from "react";
|
||||
import { waitForRemotePeer } from "@waku/core";
|
||||
import { createFullNode, createLightNode, createRelayNode } from "@waku/create";
|
||||
import type { FullNode, LightNode, RelayNode, Waku } from "@waku/interfaces";
|
||||
@ -22,11 +22,11 @@ const useCreateNode = <N extends Waku, T = {}>(
|
||||
): CrateWakuHook<N> => {
|
||||
const { factory, options, protocols = [] } = params;
|
||||
|
||||
const [node, setNode] = useState<N | null>(null);
|
||||
const [isLoading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<null | string>(null);
|
||||
const [node, setNode] = React.useState<N | null>(null);
|
||||
const [isLoading, setLoading] = React.useState<boolean>(true);
|
||||
const [error, setError] = React.useState<null | string>(null);
|
||||
|
||||
useEffect(() => {
|
||||
React.useEffect(() => {
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import React from "react";
|
||||
import type { IDecodedMessage, IDecoder, Waku } from "@waku/interfaces";
|
||||
|
||||
import type { HookState } from "./types";
|
||||
@ -17,18 +17,18 @@ export const useFilterSubscribe = (
|
||||
): UseFilterSubscribeResult => {
|
||||
const { waku, decoder } = params;
|
||||
|
||||
const [error, setError] = useState<null | string>(null);
|
||||
const [isLoading, setLoading] = useState<boolean>(false);
|
||||
const [messages, setMessage] = useState<IDecodedMessage[]>([]);
|
||||
const [error, setError] = React.useState<null | string>(null);
|
||||
const [isLoading, setLoading] = React.useState<boolean>(false);
|
||||
const [messages, setMessage] = React.useState<IDecodedMessage[]>([]);
|
||||
|
||||
const pushMessage = useCallback(
|
||||
const pushMessage = React.useCallback(
|
||||
(message: IDecodedMessage): void => {
|
||||
setMessage((prev) => [...prev, message]);
|
||||
},
|
||||
[setMessage],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
React.useEffect(() => {
|
||||
let unsubscribe: null | (() => Promise<void>) = null;
|
||||
setLoading(true);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user