1"use strict";(self.webpackChunkreact_native_website=self.webpackChunkreact_native_website||[]).push([["12508"],{11241(e,n,t){t.r(n),t.d(n,{metadata:()=>a,default:()=>v,frontMatter:()=>c,contentTitle:()=>d,toc:()=>p,assets:()=>u});var a=JSON.parse('{"id":"headless-js-android","title":"Headless JS","description":"Headless JS is a way to run tasks in JavaScript while your app is in the background. It can be used, for example, to sync fresh data, handle push notifications, or play music.","source":"@site/versioned_docs/version-0.87/headless-js-android.md","sourceDirName":".","slug":"/headless-js-android","permalink":"/docs/headless-js-android","draft":false,"unlisted":false,"editUrl":"[{\\"label\\":\\"Edit page for next release\\",\\"href\\":\\"https://github.com/facebook/react-native-website/edit/main/docs/headless-js-android.md\\"},{\\"label\\":\\"Edit page for current release\\",\\"href\\":\\"https://github.com/facebook/react-native-website/edit/main/website/versioned_docs/version-0.87/headless-js-android.md\\"}]","tags":[],"version":"0.87","lastUpdatedAt":1786551066000,"frontMatter":{"id":"headless-js-android","title":"Headless JS"},"sidebar":"docs","previous":{"title":"Create a Library for Your Module","permalink":"/docs/the-new-architecture/create-module-library"},"next":{"title":"Publishing to Google Play Store","permalink":"/docs/signed-apk-android"}}'),r=t(62540),i=t(43023),s=t(77779),o=t(98263),l=t(38469);let c={id:"headless-js-android",title:"Headless JS"},d,u={},p=[{value:"The JS API",id:"the-js-api",level:2},{value:"The Platform API",id:"the-platform-api",level:2},{value:"Retries",id:"retries",level:2},{value:"Caveats",id:"caveats",level:2},{value:"Example Usage",id:"example-usage",level:2}];function h(e){let n={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{children:"Headless JS is a way to run tasks in JavaScript while your app is in the background. It can be used, for example, to sync fresh data, handle push notifications, or play music."}),"\n",(0,r.jsx)(n.h2,{id:"the-js-api",children:"The JS API"}),"\n",(0,r.jsxs)(n.p,{children:["A task is an async function that you register on ",(0,r.jsx)(n.code,{children:"AppRegistry"}),", similar to registering React applications:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-tsx",metastring:'title="React TSX"',children:"import {AppRegistry} from 'react-native';\nAppRegistry.registerHeadlessTask('SomeTaskName', () =>\n require('SomeTaskName'),\n);\n"})}),"\n",(0,r.jsxs)(n.p,{children:["Then, in ",(0,r.jsx)(n.code,{children:"SomeTaskName.js"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-tsx",metastring:'title="React TSX"',children:"module.exports = async taskData => {\n // do stuff\n};\n"})}),"\n",(0,r.jsx)(n.p,{children:'You can do anything in your task such as network requests, timers and so on, as long as it doesn\'t touch UI. Once your task completes (i.e. the promise is resolved), React Native will go into "paused" mode (unless there are other tasks running, or there is a foreground app).'}),"\n",(0,r.jsx)(n.h2,{id:"the-platform-api",children:"The Platform API"}),"\n",(0,r.jsxs)(n.p,{children:["Yes, this does still require some native code, but it's pretty thin. You need to extend ",(0,r.jsx)(n.code,{children:"HeadlessJsTaskService"})," and override ",(0,r.jsx)(n.code,{children:"getTaskConfig"}),", e.g.:"]}),"\n",(0,r.jsxs)(s.A,{groupId:"android-language",queryString:!0,defaultValue:l.A.defaultAndroidLanguage,values:l.A.androidLanguages,children:[(0,r.jsx)(o.A,{value:"java",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",metastring:'title="Java"',children:'package com.your_application_name;\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimport com.facebook.react.HeadlessJsTaskService;\nimport com.facebook.react.bridge.Arguments;\nimport com.facebook.react.jstasks.HeadlessJsTaskConfig;\nimport javax.annotation.Nullable;\n\npublic class MyTaskService extends HeadlessJsTaskService {\n\n @Override\n protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {\n Bundle extras = intent.getExtras();\n if (extras != null) {\n return new HeadlessJsTaskConfig(\n "SomeTaskName",\n Arguments.fromBundle(extras),\n 5000, // timeout in milliseconds for the task\n false // optional: defines whether or not the task is allowed in foreground. Default is false\n );\n }\n return null;\n }\n}\n'})})}),(0,r.jsx)(o.A,{value:"kotlin",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-kotlin",metastring:'title="Kotlin"',children:'package com.your_application_name;\n\nimport android.content.Intent\nimport com.facebook.react.HeadlessJsTaskService\nimport com.facebook.react.bridge.Arguments\nimport com.facebook.react.jstasks.HeadlessJsTaskConfig\n\nclass MyTaskService : HeadlessJsTaskService() {\n override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig? {\n return intent.extras?.let {\n HeadlessJsTaskConfig(\n "SomeTaskName",\n Arguments.fromBundle(it),\n 5000, // timeout for the task\n false // optional: defines whether or not the task is allowed in foreground.\n // Default is false\n )\n }\n }\n}\n\n'})})})]}),"\n",(0,r.jsxs)(n.p,{children:["Then add the service to your ",(0,r.jsx)(n.code,{children:"AndroidManifest.xml"})," file inside the ",(0,r.jsx)(n.code,{children:"application"})," tag:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-xml",metastring:'title="XML"',children:'<service android:name="
1com.example.MyTaskService" />\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Now, whenever you ",(0,r.jsx)(n.a,{href:"https://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)",children:"start your service"}),", e.g. as a periodic task or in response to some system event / broadcast, JS will spin up, run your task, then spin down."]}),"\n",(0,r.jsx)(n.p,{children:"Example:"}),"\n",(0,r.jsxs)(s.A,{groupId:"android-language",queryString:!0,defaultValue:l.A.defaultAndroidLanguage,values:l.A.androidLanguages,children:[(0,r.jsx)(o.A,{value:"java",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",metastring:'title="Java"',children:'Intent service = new Intent(getApplicationContext(), MyTaskService.class);\nBundle bundle = new Bundle();\n\nbundle.putString("foo", "bar");\nservice.putExtras(bundle);\n\ngetApplicationContext().startForegroundService(service);\n'})})}),(0,r.jsx)(o.A,{value:"kotlin",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-kotlin",metastring:'title="Kotlin"',children:'val service = Intent(applicationContext, MyTaskService::class.java)\nval bundle = Bundle()\n\nbundle.putString("foo", "bar")\n\nservice.putExtras(bundle)\n\napplicationContext.startForegroundService(service)\n'})})})]}),"\n",(0,r.jsx)(n.h2,{id:"retries",children:"Retries"}),"\n",(0,r.jsxs)(n.p,{children:["By default, the headless JS task will not perform any retries. In order to do so, you need to create a ",(0,r.jsx)(n.code,{children:"HeadlessJsRetryPolicy"})," and throw a specific ",(0,r.jsx)(n.code,{children:"Error"}),"."]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"LinearCountingRetryPolicy"})," is an implementation of ",(0,r.jsx)(n.code,{children:"HeadlessJsRetryPolicy"})," that allows you to specify a maximum number of retries with a fixed delay between each attempt. If that does not suit your needs then you can implement your own ",(0,r.jsx)(n.code,{children:"HeadlessJsRetryPolicy"}),". These policies can be passed as an extra argument to the ",(0,r.jsx)(n.code,{children:"HeadlessJsTaskConfig"})," constructor, e.g."]}),"\n",(0,r.jsxs)(s.A,{groupId:"android-language",queryString:!0,defaultValue:l.A.defaultAndroidLanguage,values:l.A.androidLanguages,children:[(0,r.jsx)(o.A,{value:"java",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",metastring:'title="Java"',children:"HeadlessJsRetryPolicy retryPolicy = new LinearCountingRetryPolicy(\n 3, // Max number of retry attempts\n 1000 // Delay between each retry attempt\n);\n\nreturn new HeadlessJsTaskConfig(\n 'SomeTaskName',\n Arguments.fromBundle(extras),\n 5000,\n false,\n retryPolicy\n);\n"})})}),(0,r.jsx)(o.A,{value:"kotlin",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-kotlin",metastring:'title="Kotlin"',children:'val retryPolicy: HeadlessJsTaskRetryPolicy =\n LinearCountingRetryPolicy(\n 3, // Max number of retry attempts\n 1000 // Delay between each retry attempt\n )\n\nreturn HeadlessJsTaskConfig("SomeTaskName", Arguments.fromBundle(extras), 5000, false, retryPolicy)\n'})})})]}),"\n",(0,r.jsxs)(n.p,{children:["A retry attempt will only be made when a specific ",(0,r.jsx)(n.code,{children:"Error"})," is thrown. Inside a headless JS task, you can import the error and throw it when a retry attempt is required."]}),"\n",(0,r.jsx)(n.p,{children:"Example:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-tsx",metastring:'title="React TSX"',children:"import {HeadlessJsTaskError} from 'HeadlessJsTask';\n\nmodule.exports = async taskData => {\n const condition = ...;\n if (!condition) {\n throw new HeadlessJsTaskError();\n }\n};\n"})}),"\n",(0,r.jsx)(n.p,{children:"If you wish all errors to cause a retry attempt, you will need to catch them and throw the above error."}),"\n",(0,r.jsx)(n.h2,{id:"caveats",children:"Caveats"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["By default, your app will crash if you try to run a task while the app is in the foreground. This is to prevent developers from shooting themselves in the foot by doing a lot of work in a task and slowing the UI. You can pass a fourth ",(0,r.jsx)(n.code,{children:"boolean"})," argument to control this behaviour."]}),"\n",(0,r.jsxs)(n.li,{children:["If you start your service from a ",(0,r.jsx)(n.code,{children:"BroadcastReceiver"}),", make sure to call ",(0,r.jsx)(n.code,{children:"HeadlessJsTaskService.acquireWakeLockNow()"})," before returning from ",(0,r.jsx)(n.code,{children:"onReceive()"}),"."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"example-usage",children:"Example Usage"}),"\n",(0,r.jsx)(n.p,{children:"Service can be started from Java API. First you need to decide when the service should be started and implement your solution accordingly. Here is an example that reacts to network connection change."}),"\n",(0,r.jsx)(n.p,{children:"Following lines shows part of Android manifest file for registering broadcast receiver."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-xml",metastring:'title="XML"',children:'<receiver android:name=".NetworkChangeReceiver" >\n <intent-filter>\n <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />\n </intent-filter>\n</receiver>\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Broadcast receiver then handles intent that was broadcasted in onReceive function. This is a great place to check whether your app is on foreground or not. If app is not on foreground we can prepare our intent to be started, with no information or additional information bundled using ",(0,r.jsx)(n.code,{children:"putExtra"})," (keep in mind bundle can handle only parcelable values). In the end service is started and wakelock is acquired."]}),"\n",(0,r.jsxs)(s.A,{groupId:"android-language",queryString:!0,defaultValue:l.A.defaultAndroidLanguage,values:l.A.androidLanguages,children:[(0,r.jsx)(o.A,{value:"java",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",metastring:'title="Java"',children:'import android.app.ActivityManager;\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.net.ConnectivityManager;\nimport android.net.Network;\nimport android.net.NetworkCapabilities;\nimport android.net.NetworkInfo;\nimport android.os.Build;\n\nimport com.facebook.react.HeadlessJsTaskService;\n\npublic class NetworkChangeReceiver extends BroadcastReceiver {\n\n @Override\n public void onReceive(final Context context, final Intent intent) {\n /**\n This part will be called every time network connection is changed\n e.g. Connected -> Not Connected\n **/\n if (!isAppOnForeground((context))) {\n /**\n We will start our service and send extra info about\n network connections\n **/\n boolean hasInternet = isNetworkAvailable(context);\n Intent serviceIntent = new Intent(context, MyTaskService.class);\n serviceIntent.putExtra("hasInternet", hasInternet);\n context.startForegroundService(serviceIntent);\n HeadlessJsTaskService.acquireWakeLockNow(context);\n }\n }\n\n private boolean isAppOnForeground(Context context) {\n /**\n We need to check if app is in foreground otherwise the app will crash.\n https://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not\n **/\n ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);\n List<ActivityManager.RunningAppProcessInfo> appProcesses =\n activityManager.getRunningAppProcesses();\n if (appProcesses == null) {\n return false;\n }
1\n final String packageName = context.getPackageName();\n for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {\n if (appProcess.importance ==\n ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND &&\n appProcess.processName.equals(packageName)) {\n return true;\n }\n }\n return false;\n }\n\n public static boolean isNetworkAvailable(Context context) {\n ConnectivityManager cm = (ConnectivityManager)\n context.getSystemService(Context.CONNECTIVITY_SERVICE);\n\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n Network networkCapabilities = cm.getActiveNetwork();\n\n if(networkCapabilities == null) {\n return false;\n }\n\n NetworkCapabilities actNw = cm.getNetworkCapabilities(networkCapabilities);\n\n if(actNw == null) {\n return false;\n }\n\n if(actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) || actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) || actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {\n return true;\n }\n\n return false;\n }\n\n // deprecated in API level 29\n NetworkInfo netInfo = cm.getActiveNetworkInfo();\n return (netInfo != null && netInfo.isConnected());\n }\n}\n'})})}),(0,r.jsx)(o.A,{value:"kotlin",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-kotlin",metastring:'title="Kotlin"',children:'import android.app.ActivityManager\nimport android.app.ActivityManager.RunningAppProcessInfo\nimport android.content.BroadcastReceiver\nimport android.content.Context\nimport android.content.Intent\nimport android.net.ConnectivityManager\nimport android.net.NetworkCapabilities\nimport android.os.Build\nimport com.facebook.react.HeadlessJsTaskService\n\nclass NetworkChangeReceiver : BroadcastReceiver() {\n override fun onReceive(context: Context, intent: Intent?) {\n /**\n * This part will be called every time network connection is changed e.g. Connected -> Not\n * Connected\n */\n if (!isAppOnForeground(context)) {\n /** We will start our service and send extra info about network connections */\n val hasInternet = isNetworkAvailable(context)\n val serviceIntent = Intent(context, MyTaskService::class.java)\n serviceIntent.putExtra("hasInternet", hasInternet)\n context.startForegroundService(serviceIntent)\n HeadlessJsTaskService.acquireWakeLockNow(context)\n }\n }\n\n private fun isAppOnForeground(context: Context): Boolean {\n /**\n * We need to check if app is in foreground otherwise the app will crash.\n * https://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not\n */\n val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager\n val appProcesses = activityManager.runningAppProcesses ?: return false\n val packageName: String = context.getPackageName()\n for (appProcess in appProcesses) {\n if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND &&\n appProcess.processName == packageName\n ) {\n return true\n }\n }\n return false\n }\n\n companion object {\n fun isNetworkAvailable(context: Context): Boolean {\n val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager\n var result = false\n\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n val networkCapabilities = cm.activeNetwork ?: return false\n\n val actNw = cm.getNetworkCapabilities(networkCapabilities) ?: return false\n\n result =\n when {\n actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true\n actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true\n actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true\n else -> false\n }\n\n return result\n } else {\n cm.run {\n // deprecated
1in API level 29\n cm.activeNetworkInfo?.run {\n result =\n when (type) {\n ConnectivityManager.TYPE_WIFI -> true\n ConnectivityManager.TYPE_MOBILE -> true\n ConnectivityManager.TYPE_ETHERNET -> true\n else -> false\n }\n }\n }\n }\n return result\n }\n }\n}\n\n'})})})]})]})}function v(e={}){let{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},98263(e,n,t){t.d(n,{A:()=>o});var a=t(62540);t(63696);var r=t(11750),i=t(23865);function s({children:e,className:n,hidden:t}){return(0,a.jsx)("div",{role:"tabpanel",className:(0,r.A)("tabItem_wHwb",n),hidden:t,children:e})}function o({children:e,className:n,value:t}){let{selectedValue:r,lazy:l}=(0,i.uc)(),c=t===r;return!c&&l?null:(0,a.jsx)(s,{className:n,hidden:!c,children:e})}},77779(e,n,t){t.d(n,{A:()=>p});var a=t(62540);t(63696);var r=t(11750),i=t(46065),s=t(23865),o=t(45194),l=t(83029);function c({className:e}){let{selectedValue:n,selectValue:t,tabValues:i,block:l}=(0,s.uc)(),d=[],{blockElementScrollPositionUntilNextRender:u}=(0,o.a_)(),p=e=>{let a=e.currentTarget,r=i[d.indexOf(a)].value;r!==n&&(u(a),t(r))},h=e=>{let n=null;switch(e.key){case"Enter":p(e);break;case"ArrowRight":{let t=d.indexOf(e.currentTarget)+1;n=d[t]??d[0];break}case"ArrowLeft":{let t=d.indexOf(e.currentTarget)-1;n=d[t]??d[d.length-1]}}n?.focus()};return(0,a.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":l},e),children:i.map(({value:e,label:t,attributes:i})=>(0,a.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:e=>{d.push(e)},onKeyDown:h,onClick:p,...i,className:(0,r.A)("tabs__item","tabItem_l0OV",i?.className,{"tabs__item--active":n===e}),children:t??e},e))})}function d({children:e}){return(0,a.jsx)("div",{className:"margin-top--md",children:e})}function u({className:e,children:n}){return(0,a.jsxs)("div",{className:(0,r.A)(i.G.tabs.container,"tabs-container","tabList_J5MA"),children:[(0,a.jsx)(c,{className:e}),(0,a.jsx)(d,{children:n})]})}function p(e){let n=(0,l.A)(),t=(0,s.OC)(e);return(0,a.jsx)(s.O_,{value:t,children:(0,a.jsx)(u,{className:e.className,children:(0,s.vT)(e.children)})},String(n))}},23865(e,n,t){t.d(n,{OC:()=>p,O_:()=>m,uc:()=>v,vT:()=>d});var a=t(62540),r=t(63696),i=t(49519),s=t(6743),o=t(88511),l=t(15396),c=t(89030);function d(e){return r.Children.toArray(e).filter(e=>"\n"!==e)}function u({value:e,tabValues:n}){return n.some(n=>n.value===e)}function p(e){let n,{defaultValue:t,queryString:a=!1,groupId:d}=e,p=function(e){let{values:n,children:t}=e;return(0,r.useMemo)(()=>{let e=n??r.Children.toArray(t).flatMap(e=>{if(!e)return[];if((0,r.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return[e];let n="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${n}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop. 2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:n,attributes:t,default:a}})=>({value:e,label:n,attributes:t,default:a})),a=(0,l.XI)(e,(e,n)=>e.value===n.value);if(a.length>0)throw Error(`Docusaurus error: Duplicate values "${a.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,t])}(e),[h,v]=(0,r.useState)(()=>(function({defaultValue:e,tabValues:n}){if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!u({value:e,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let t=n.find(e=>e.default)??n[0];if(!t)throw Error("Unexpected error: 0 tabValues");return t.value})({defaultValue:t,tabValues:p})),[m,g]=function({queryString:e=!1,groupId:n}){let t=(0,i.W6)(),a=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,o.aZ)(a),(0,r.useCallback)(e=>{if(!a)return;let n=new URLSearchParams(t.location.search);n.set(a,e),t.replace({...t.location,search:n.toString()})},[a,t])]}({queryString:a,groupId:d}),[f,x]=function({groupId:e}){let n=e?`docusaurus.tab.${e}`:null,[t,a]=(0,c.Dv)(n);return[t,(0,r.useCallback)(e=>{n&&a.set(e)},[n,a])]}({groupId:d}),b=u({value:n=m??f,tabValues:p})?n:null;return(0,s.A)(()=>{b&&v(b)},[b]),{selectedValue:h,selectValue:(0,r.useCallback)(e=>{if(!u({value:e,tabValues:p}))throw Error(`Can't select invalid tab value=${e}`);v(e),g(e),x(e)},[g,x,p]),tabValues:p,lazy:e.lazy??!1,block:e.block??!1}}let h=(0,r.createContext)(null);function v(){let e=r.useContext(h);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function m(e){return(0,a.jsx)(h.Provider,{value:e.value,children:e.children})}},38469(e,n,t){t.d(n,{A:()=>s});var a=t(93227);let r=!!a.A.canUseDOM&&navigator.platform.startsWith("Mac"),i=!!a.A.canUseDOM&&navigator.platform.startsWith("Win"),s={defaultGuide:"quickstart",defaultJsDebugger:"flipper",defaultOs:r?"macos":i?"windows":"linux",defaultPackageManager:"npm",defaultPlatform:r?"ios":"android",defaultSyntax:"functional",defaultAndroidLanguage:"java",defaultAppleLanguage:"objc",defaultJavaScriptSpecLanguages:"typescript",getDevNotesTabs:(e=["android","ios","web","windows"])=>[e.includes("android")?{label:"Android",value:"android"}:void 0,e.includes("ios")?{label:"iOS",value:"ios"}:void 0,e.includes("web")?{label:"Web",value:"web"}:void 0,e.includes("windows")?{label:"Windows",value:"windows"}
2:void 0].filter(Boolean),guides:[{label:"Expo Go Quickstart",value:"quickstart"},{label:"React Native CLI Quickstart",value:"native"}],oses:[{label:"macOS",value:"macos"},{label:"Windows",value:"windows"},{label:"Linux",value:"linux"}],packageManagers:[{label:"npm",value:"npm"},{label:"Yarn",value:"yarn"}],platforms:[{label:"Android",value:"android"},{label:"iOS",value:"ios"}],syntax:[{label:"Function Component",value:"functional"},{label:"Class Component",value:"classical"}],androidLanguages:[{label:"Java",value:"java"},{label:"Kotlin",value:"kotlin"}],appleLanguages:[{label:"ObjectiveC",value:"objc"},{label:"Swift",value:"swift"}],javaScriptSpecLanguages:[{label:"TypeScript",value:"typescript"},{label:"Flow",value:"flow"}],jsDebuggers:[{label:"Hermes Debugger / Expo",value:"hermes"},{label:"Flipper",value:"flipper"},{label:"New Debugger (Experimental)",value:"new-debugger"}],snackLanguages:[{label:"TypeScript",value:"typescript"},{label:"JavaScript",value:"javascript"}],defaultSnackLanguage:"typescript"}},43023(e,n,t){t.d(n,{R:()=>s,x:()=>o});var a=t(63696);let r={},i=a.createContext(r);function s(e){let n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),a.createElement(i.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.