context of portals

This commit is contained in:
gustavo-em
2022-02-24 16:08:12 -03:00
parent 6a5acf1084
commit 29394335af
4 changed files with 32 additions and 12 deletions

View 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>
</>
)
}

View File

@@ -0,0 +1,2 @@
import React, { createContext } from 'react'
export const PortalContext = createContext(false);

View 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;
}

View File

@@ -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>
</>
)
}