react-native-root-siblings
Advanced tools
Comparing version
@@ -50,5 +50,7 @@ import React, { Component } from 'react'; | ||
this.siblingsPool = siblings; | ||
this.setState({ | ||
siblings | ||
}, () => this.invokeCallback(updateCallback)); | ||
setImmediate(() => { | ||
this.setState({ | ||
siblings | ||
}, () => this.invokeCallback(updateCallback)); | ||
}); | ||
}); | ||
@@ -55,0 +57,0 @@ } |
@@ -47,3 +47,13 @@ import React, { useEffect, useState } from 'react'; | ||
const { inactive } = props; | ||
const [sibling, setSibling] = useState(null); | ||
const [sibling] = useState(() => { | ||
const { Root: Parent, manager: parentManager } = wrapRootComponent(ChildrenWrapper, renderSibling); | ||
managerStack.push(parentManager); | ||
if (inactive) { | ||
inactiveManagers.add(parentManager); | ||
} | ||
return { | ||
Root: Parent, | ||
manager: parentManager | ||
}; | ||
}); | ||
useEffect(() => { | ||
@@ -65,27 +75,8 @@ return () => { | ||
} | ||
if (!sibling) { | ||
const { Root: Parent, manager: parentManager } = wrapRootComponent(ChildrenWrapper, renderSibling); | ||
managerStack.push(parentManager); | ||
if (inactive) { | ||
inactiveManagers.add(parentManager); | ||
} | ||
setSibling({ | ||
Root: Parent, | ||
manager: parentManager | ||
}); | ||
return <Parent>{props.children}</Parent>; | ||
} | ||
else { | ||
const Parent = sibling.Root; | ||
return <Parent>{props.children}</Parent>; | ||
} | ||
const Parent = sibling.Root; | ||
return <Parent>{props.children}</Parent>; | ||
} | ||
export function RootSiblingPortal(props) { | ||
const [sibling, setSibling] = useState(null); | ||
if (!sibling) { | ||
setSibling(new RootSiblingsManager(props.children)); | ||
} | ||
else { | ||
sibling.update(props.children); | ||
} | ||
const [sibling] = useState(() => new RootSiblingsManager(null)); | ||
sibling.update(props.children); | ||
useEffect(() => { | ||
@@ -92,0 +83,0 @@ if (sibling) { |
{ | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"name": "react-native-root-siblings", | ||
@@ -4,0 +4,0 @@ "repository": { |
@@ -82,3 +82,3 @@ ## react-native-root-siblings [](http://badge.fury.io/js/react-native-root-siblings) | ||
<RootSiblingPortal> | ||
<View style={[StyleSheet.absoluteFull, { backgroundColor: 'rgba(0, 0, 0, 0.25)' }]} /> | ||
<View style={[StyleSheet.absoluteFill, { backgroundColor: 'rgba(0, 0, 0, 0.25)' }]} /> | ||
</RootSiblingPortal> | ||
@@ -85,0 +85,0 @@ ) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36949
-1.09%713
-1.66%