typescript on frontend

This commit is contained in:
Jan Prochazka
2020-01-09 22:30:53 +01:00
parent 20a55fdd7c
commit c819aac098
17 changed files with 139 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
import io from 'socket.io-client';
import React from 'react';
const SocketContext = React.createContext();
const SocketContext = React.createContext(null);
export function SocketProvider({ children }) {
const [socket, setSocket] = React.useState();

View File

@@ -1,7 +1,7 @@
import React from 'react';
function createGlobalState(defaultValue) {
const Context = React.createContext();
const Context = React.createContext(null);
function Provider({ children }) {
const [currentvalue, setCurrentValue] = React.useState(defaultValue);

View File

@@ -2,7 +2,7 @@ import React from 'react';
import axios from './axios';
import useSocket from './SocketProvider';
export default function useFetch({ defaultValue, reloadTrigger, url, ...config }) {
export default function useFetch({ url, defaultValue = undefined, reloadTrigger = undefined, ...config }) {
const [value, setValue] = React.useState(defaultValue);
const [loadCounter, setLoadCounter] = React.useState(0);
const socket = useSocket();