You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
2.5 KiB

{"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,4BAAG;IACf,MAAM,IAAIC,KAAK,CAACJ,qBAAqB,CAAC;EACxC,CAAC;EACDK,YAAY,0BAAG;IACb,MAAM,IAAID,KAAK,CAACJ,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;AASF,eAAe,SAASM,iBAAiB,CAACC,QAAoB,EAAE;EAC9D,wBAAyCR,KAAK,CAACS,UAAU,CACvDP,qBAAqB,CACtB;IAFOE,cAAc,qBAAdA,cAAc;IAAEE,YAAAA,qBAAAA,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"}