context of portals
This commit is contained in:
19
react-native/app/contexts/portals/container.tsx
Normal file
19
react-native/app/contexts/portals/container.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react'
|
||||
import { PortalContext } from './context'
|
||||
type IPortalContext = {
|
||||
portals?: any
|
||||
setPortals?: any
|
||||
}
|
||||
|
||||
export const PortalContextContainer = ({children}: any)=>{
|
||||
const [portals, setPortals] = React.useState(0)
|
||||
const portalHook: IPortalContext = {portals, setPortals}
|
||||
return (
|
||||
<>
|
||||
<PortalContext.Provider value={portalHook}>
|
||||
{children}
|
||||
</PortalContext.Provider>
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
2
react-native/app/contexts/portals/context.ts
Normal file
2
react-native/app/contexts/portals/context.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import React, { createContext } from 'react'
|
||||
export const PortalContext = createContext(false);
|
||||
11
react-native/app/contexts/portals/hook.ts
Normal file
11
react-native/app/contexts/portals/hook.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { PortalContext } from './context';
|
||||
type IPortalContext = {
|
||||
portals?: any
|
||||
setPortals?: any
|
||||
}
|
||||
|
||||
export const usePortal = (): IPortalContext=>{
|
||||
const contextOfPortals = useContext(PortalContext);
|
||||
return contextOfPortals as IPortalContext;
|
||||
}
|
||||
12
react-native/app/pages/list_portals/component.js
vendored
12
react-native/app/pages/list_portals/component.js
vendored
@@ -1,12 +0,0 @@
|
||||
import React from 'react'
|
||||
import { Text, View } from 'react-native';
|
||||
|
||||
export const ListPortals = ()=>{
|
||||
return (
|
||||
<>
|
||||
<View style={{marginTop: 10}}>
|
||||
<Text style={{color: 'black'}}>List</Text>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user