Skip to content

Commit

Permalink
v0.3.2 FIX dialog methods should check hiddenRef instead of hidden state
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyao91 committed Sep 25, 2019
1 parent df8495a commit 0f123b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-bootstrap-easy-dialog",
"version": "0.3.1",
"version": "0.3.2",
"description": "React Bootstrap Dialog made easy",
"keywords": [
"react-bootstrap",
Expand Down
4 changes: 3 additions & 1 deletion src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function DialogProvider({ children, ...providerOptions }) {
const [show, setShow] = useState(false);
const [showOptions, setShowOptions] = useState({});
const [hidden, setHidden] = useState(true);
const hiddenRef = useRef(hidden);
const previousHiddenRef = useRef(hidden);
const resolveDoneRef = useRef(null);
const resolveHiddenRef = useRef(null);
Expand Down Expand Up @@ -44,6 +45,7 @@ export function DialogProvider({ children, ...providerOptions }) {
}

useEffect(() => {
hiddenRef.current = hidden;
const previousHidden = previousHiddenRef.current;
previousHiddenRef.current = hidden;
if (previousHidden === false && hidden === true) {
Expand All @@ -54,7 +56,7 @@ export function DialogProvider({ children, ...providerOptions }) {
const dialog = useMemo(() => {
function buildMethod(methodOptions, failValue, okValue) {
return function(text, userOptions) {
if (!hidden) return failValue;
if (!hiddenRef.current) return failValue;

setShow(true);
setHidden(false);
Expand Down

0 comments on commit 0f123b5

Please sign in to comment.