mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-23 10:07:30 +02:00
feat(frontend): server side rendering to improve performance
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import configService from "../services/config.service";
|
||||
import Config from "../types/config.type";
|
||||
import { ConfigHook } from "../types/config.type";
|
||||
|
||||
export const ConfigContext = createContext<Config[] | null>(null);
|
||||
export const ConfigContext = createContext<ConfigHook>({
|
||||
configVariables: [],
|
||||
refresh: () => {},
|
||||
});
|
||||
|
||||
const useConfig = () => {
|
||||
const configVariables = useContext(ConfigContext) as Config[];
|
||||
const configContext = useContext(ConfigContext);
|
||||
return {
|
||||
get: (key: string) => configService.get(key, configVariables),
|
||||
get: (key: string) => configService.get(key, configContext.configVariables),
|
||||
refresh: () => configContext.refresh(),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { UserHook } from "../types/user.type";
|
||||
|
||||
export const UserContext = createContext<UserHook>({
|
||||
user: null,
|
||||
setUser: () => {},
|
||||
refreshUser: async () => null,
|
||||
});
|
||||
|
||||
const useUser = () => {
|
||||
|
||||
Reference in New Issue
Block a user