{"ast":null,"code":"import * as React from 'react';\nvar MISSING_CONTEXT_ERROR = \"Couldn't find a schedule context.\";\nexport var ScheduleUpdateContext = React.createContext({\n  scheduleUpdate: function scheduleUpdate() {\n    throw new Error(MISSING_CONTEXT_ERROR);\n  },\n  flushUpdates: function flushUpdates() {\n    throw new Error(MISSING_CONTEXT_ERROR);\n  }\n});\nexport default function useScheduleUpdate(callback) {\n  var _React$useContext = React.useContext(ScheduleUpdateContext),\n    scheduleUpdate = _React$useContext.scheduleUpdate,\n    flushUpdates = _React$useContext.flushUpdates;\n  scheduleUpdate(callback);\n  React.useEffect(flushUpdates);\n}","map":{"version":3,"sources":["useScheduleUpdate.tsx"],"names":["React","MISSING_CONTEXT_ERROR","ScheduleUpdateContext","createContext","scheduleUpdate","Error","flushUpdates","useScheduleUpdate","callback","useContext","useEffect"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,IAAMC,qBAAqB,GAAG,mCAAmC;AAEjE,OAAO,IAAMC,qBAAqB,GAAGF,KAAK,CAACG,aAAa,CAGrD;EACDC,cAAc,WAAA,eAAA,EAAG;IACf,MAAM,IAAIC,KAAK,CAACJ,qBAAqB,CAAC;EACxC,CAAC;EACDK,YAAY,WAAA,aAAA,EAAG;IACb,MAAM,IAAID,KAAK,CAACJ,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;AASF,eAAe,SAASM,iBAAiB,CAACC,QAAoB,EAAE;EAC9D,IAAA,iBAAA,GAAyCR,KAAK,CAACS,UAAU,CACvDP,qBAAqB,CACtB;IAFOE,cAAc,GAAA,iBAAA,CAAdA,cAAc;IAAEE,YAAAA,GAAAA,iBAAAA,CAAAA,YAAAA;EAIxBF,cAAc,CAACI,QAAQ,CAAC;EAExBR,KAAK,CAACU,SAAS,CAACJ,YAAY,CAAC;AAC/B","sourceRoot":"../../src","sourcesContent":["import * as React from 'react';\nconst MISSING_CONTEXT_ERROR = \"Couldn't find a schedule context.\";\nexport const ScheduleUpdateContext = /*#__PURE__*/React.createContext({\n  scheduleUpdate() {\n    throw new Error(MISSING_CONTEXT_ERROR);\n  },\n  flushUpdates() {\n    throw new Error(MISSING_CONTEXT_ERROR);\n  }\n});\n\n/**\n * When screen config changes, we want to update the navigator in the same update phase.\n * However, navigation state is in the root component and React won't let us update it from a child.\n * This is a workaround for that, the scheduled update is stored in the ref without actually calling setState.\n * It lets all subsequent updates access the latest state so it stays correct.\n * Then we call setState during after the component updates.\n */\nexport default function useScheduleUpdate(callback) {\n  const {\n    scheduleUpdate,\n    flushUpdates\n  } = React.useContext(ScheduleUpdateContext);\n  scheduleUpdate(callback);\n  React.useEffect(flushUpdates);\n}\n//# sourceMappingURL=useScheduleUpdate.js.map"]},"metadata":{},"sourceType":"module"}