R: Remove .Provider from Contexts
This commit is contained in:
parent
aa4a8b3f94
commit
07919cd912
|
@ -21,5 +21,5 @@ export const useAccessMode = () => {
|
||||||
|
|
||||||
export const AccessModeState = ({ children }: React.PropsWithChildren) => {
|
export const AccessModeState = ({ children }: React.PropsWithChildren) => {
|
||||||
const [accessLevel, setAccessLevel] = useState<UserLevel>(UserLevel.READER);
|
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]);
|
}, [reload]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContext.Provider
|
<AuthContext
|
||||||
value={{
|
value={{
|
||||||
user,
|
user,
|
||||||
login,
|
login,
|
||||||
|
@ -202,6 +202,6 @@ export const AuthState = ({ children }: React.PropsWithChildren) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</AuthContext.Provider>
|
</AuthContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
|
||||||
}, [noNavigation]);
|
}, [noNavigation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OptionsContext.Provider
|
<OptionsContext
|
||||||
value={{
|
value={{
|
||||||
darkMode,
|
darkMode,
|
||||||
adminMode,
|
adminMode,
|
||||||
|
@ -169,6 +169,6 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</>
|
</>
|
||||||
</OptionsContext.Provider>
|
</OptionsContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,7 +87,7 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GlobalOssContext.Provider
|
<GlobalOssContext
|
||||||
value={{
|
value={{
|
||||||
schema,
|
schema,
|
||||||
setID,
|
setID,
|
||||||
|
@ -102,6 +102,6 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</GlobalOssContext.Provider>
|
</GlobalOssContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -291,7 +291,7 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LibraryContext.Provider
|
<LibraryContext
|
||||||
value={{
|
value={{
|
||||||
items,
|
items,
|
||||||
folders,
|
folders,
|
||||||
|
@ -318,6 +318,6 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</LibraryContext.Provider>
|
</LibraryContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,7 +93,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
|
||||||
}, [pathname, scrollTop]);
|
}, [pathname, scrollTop]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationContext.Provider
|
<NavigationContext
|
||||||
value={{
|
value={{
|
||||||
push,
|
push,
|
||||||
replace,
|
replace,
|
||||||
|
@ -105,7 +105,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</NavigationContext.Provider>
|
</NavigationContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OssContext.Provider
|
<OssContext
|
||||||
value={{
|
value={{
|
||||||
schema: ossData.schema,
|
schema: ossData.schema,
|
||||||
itemID,
|
itemID,
|
||||||
|
@ -385,6 +385,6 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</OssContext.Provider>
|
</OssContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -549,7 +549,7 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RSFormContext.Provider
|
<RSFormContext
|
||||||
value={{
|
value={{
|
||||||
schema: rsData.schema,
|
schema: rsData.schema,
|
||||||
itemID,
|
itemID,
|
||||||
|
@ -587,6 +587,6 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</RSFormContext.Provider>
|
</RSFormContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,8 +76,8 @@ export const UserProfileState = ({ children }: React.PropsWithChildren) => {
|
||||||
}, [reload]);
|
}, [reload]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProfileContext.Provider value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}>
|
<ProfileContext value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}>
|
||||||
{children}
|
{children}
|
||||||
</ProfileContext.Provider>
|
</ProfileContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,7 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
|
||||||
}, [reload]);
|
}, [reload]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UsersContext.Provider
|
<UsersContext
|
||||||
value={{
|
value={{
|
||||||
users,
|
users,
|
||||||
reload,
|
reload,
|
||||||
|
@ -89,6 +89,6 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</UsersContext.Provider>
|
</UsersContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,7 @@ const OssEditContext = createContext<IOssEditContext | null>(null);
|
||||||
export const useOssEdit = () => {
|
export const useOssEdit = () => {
|
||||||
const context = useContext(OssEditContext);
|
const context = useContext(OssEditContext);
|
||||||
if (context === null) {
|
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;
|
return context;
|
||||||
};
|
};
|
||||||
|
@ -384,7 +384,7 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OssEditContext.Provider
|
<OssEditContext
|
||||||
value={{
|
value={{
|
||||||
schema: model.schema,
|
schema: model.schema,
|
||||||
selected,
|
selected,
|
||||||
|
@ -475,6 +475,6 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</OssEditContext.Provider>
|
</OssEditContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,7 @@ const RSEditContext = createContext<IRSEditContext | null>(null);
|
||||||
export const useRSEdit = () => {
|
export const useRSEdit = () => {
|
||||||
const context = useContext(RSEditContext);
|
const context = useContext(RSEditContext);
|
||||||
if (context === null) {
|
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;
|
return context;
|
||||||
};
|
};
|
||||||
|
@ -628,7 +628,7 @@ export const RSEditState = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RSEditContext.Provider
|
<RSEditContext
|
||||||
value={{
|
value={{
|
||||||
schema: model.schema,
|
schema: model.schema,
|
||||||
updateSchema,
|
updateSchema,
|
||||||
|
@ -785,7 +785,7 @@ export const RSEditState = ({
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</RSEditContext.Provider>
|
</RSEditContext>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1012,5 +1012,5 @@ export const prompts = {
|
||||||
|
|
||||||
// ============== INTERNAL LABELS FOR DEVELOPERS TEXT ================
|
// ============== INTERNAL LABELS FOR DEVELOPERS TEXT ================
|
||||||
export function contextOutsideScope(contextName: string, contextState: string): string {
|
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