mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
R: Remove .Provider from Contexts
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
This commit is contained in:
parent
56b7d3d71f
commit
d0fbaa7148
|
@ -21,5 +21,5 @@ export const useAccessMode = () => {
|
|||
|
||||
export const AccessModeState = ({ children }: React.PropsWithChildren) => {
|
||||
const [accessLevel, setAccessLevel] = useState<UserLevel>(UserLevel.READER);
|
||||
return <AccessContext.Provider value={{ accessLevel, setAccessLevel }}>{children}</AccessContext.Provider>;
|
||||
return <AccessContext value={{ accessLevel, setAccessLevel }}>{children}</AccessContext>;
|
||||
};
|
||||
|
|
|
@ -186,7 +186,7 @@ export const AuthState = ({ children }: React.PropsWithChildren) => {
|
|||
}, [reload]);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider
|
||||
<AuthContext
|
||||
value={{
|
||||
user,
|
||||
login,
|
||||
|
@ -202,6 +202,6 @@ export const AuthState = ({ children }: React.PropsWithChildren) => {
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
</AuthContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -127,7 +127,7 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
|
|||
}, [noNavigation]);
|
||||
|
||||
return (
|
||||
<OptionsContext.Provider
|
||||
<OptionsContext
|
||||
value={{
|
||||
darkMode,
|
||||
adminMode,
|
||||
|
@ -169,6 +169,6 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
|
|||
|
||||
{children}
|
||||
</>
|
||||
</OptionsContext.Provider>
|
||||
</OptionsContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -87,7 +87,7 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
|
|||
);
|
||||
|
||||
return (
|
||||
<GlobalOssContext.Provider
|
||||
<GlobalOssContext
|
||||
value={{
|
||||
schema,
|
||||
setID,
|
||||
|
@ -102,6 +102,6 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</GlobalOssContext.Provider>
|
||||
</GlobalOssContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -291,7 +291,7 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
|
|||
);
|
||||
|
||||
return (
|
||||
<LibraryContext.Provider
|
||||
<LibraryContext
|
||||
value={{
|
||||
items,
|
||||
folders,
|
||||
|
@ -318,6 +318,6 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</LibraryContext.Provider>
|
||||
</LibraryContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -93,7 +93,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
|
|||
}, [pathname, scrollTop]);
|
||||
|
||||
return (
|
||||
<NavigationContext.Provider
|
||||
<NavigationContext
|
||||
value={{
|
||||
push,
|
||||
replace,
|
||||
|
@ -105,7 +105,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</NavigationContext.Provider>
|
||||
</NavigationContext>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -358,7 +358,7 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
|
|||
);
|
||||
|
||||
return (
|
||||
<OssContext.Provider
|
||||
<OssContext
|
||||
value={{
|
||||
schema: ossData.schema,
|
||||
itemID,
|
||||
|
@ -385,6 +385,6 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</OssContext.Provider>
|
||||
</OssContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -549,7 +549,7 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
|
|||
);
|
||||
|
||||
return (
|
||||
<RSFormContext.Provider
|
||||
<RSFormContext
|
||||
value={{
|
||||
schema: rsData.schema,
|
||||
itemID,
|
||||
|
@ -587,6 +587,6 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</RSFormContext.Provider>
|
||||
</RSFormContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -76,8 +76,8 @@ export const UserProfileState = ({ children }: React.PropsWithChildren) => {
|
|||
}, [reload]);
|
||||
|
||||
return (
|
||||
<ProfileContext.Provider value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}>
|
||||
<ProfileContext value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}>
|
||||
{children}
|
||||
</ProfileContext.Provider>
|
||||
</ProfileContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
|
|||
}, [reload]);
|
||||
|
||||
return (
|
||||
<UsersContext.Provider
|
||||
<UsersContext
|
||||
value={{
|
||||
users,
|
||||
reload,
|
||||
|
@ -89,6 +89,6 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
|
|||
}}
|
||||
>
|
||||
{children}
|
||||
</UsersContext.Provider>
|
||||
</UsersContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -82,7 +82,7 @@ const OssEditContext = createContext<IOssEditContext | null>(null);
|
|||
export const useOssEdit = () => {
|
||||
const context = useContext(OssEditContext);
|
||||
if (context === null) {
|
||||
throw new Error('useOssEdit has to be used within <OssEditState.Provider>');
|
||||
throw new Error('useOssEdit has to be used within <OssEditState>');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
@ -384,7 +384,7 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
|
|||
);
|
||||
|
||||
return (
|
||||
<OssEditContext.Provider
|
||||
<OssEditContext
|
||||
value={{
|
||||
schema: model.schema,
|
||||
selected,
|
||||
|
@ -475,6 +475,6 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
|
|||
) : null}
|
||||
|
||||
{children}
|
||||
</OssEditContext.Provider>
|
||||
</OssEditContext>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -114,7 +114,7 @@ const RSEditContext = createContext<IRSEditContext | null>(null);
|
|||
export const useRSEdit = () => {
|
||||
const context = useContext(RSEditContext);
|
||||
if (context === null) {
|
||||
throw new Error('useRSEdit has to be used within <RSEditState.Provider>');
|
||||
throw new Error('useRSEdit has to be used within <RSEditState>');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
@ -628,7 +628,7 @@ export const RSEditState = ({
|
|||
);
|
||||
|
||||
return (
|
||||
<RSEditContext.Provider
|
||||
<RSEditContext
|
||||
value={{
|
||||
schema: model.schema,
|
||||
updateSchema,
|
||||
|
@ -785,7 +785,7 @@ export const RSEditState = ({
|
|||
) : null}
|
||||
|
||||
{children}
|
||||
</RSEditContext.Provider>
|
||||
</RSEditContext>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1012,5 +1012,5 @@ export const prompts = {
|
|||
|
||||
// ============== INTERNAL LABELS FOR DEVELOPERS TEXT ================
|
||||
export function contextOutsideScope(contextName: string, contextState: string): string {
|
||||
return `${contextName} has to be used within <${contextState}.Provider>`;
|
||||
return `${contextName} has to be used within <${contextState}>`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user