React DOM APIs
تحتوي حزمة react-dom على الوظائف المدعومة لتطبيقات الويب فقط (التي تعمل في بيئة المتصفح DOM). أي أنها غير مدعومة لـ React Native.
APIs
هذه الوظائف يمكن استيرادها في مكوناتك. لكن نادراً ما يتم استخدامها:
- تتيح لك
createPortalتقديم مكونات فرعية في جزء مختلف من شجرة DOM. - تتيح لك
flushSyncإجبار React على تفريغ تحديث الحالة وتحديث DOM بشكل متزامن.
Resource Preloading APIs
These APIs can be used to make apps faster by pre-loading resources such as scripts, stylesheets, and fonts as soon as you know you need them, for example before navigating to another page where the resources will be used.
React-based frameworks frequently handle resource loading for you, so you might not have to call these APIs yourself. Consult your framework’s documentation for details.
prefetchDNSlets you prefetch the IP address of a DNS domain name that you expect to connect to.preconnectlets you connect to a server you expect to request resources from, even if you don’t know what resources you’ll need yet.preloadlets you fetch a stylesheet, font, image, or external script that you expect to use.preloadModulelets you fetch an ESM module that you expect to use.preinitlets you fetch and evaluate an external script or fetch and insert a stylesheet.preinitModulelets you fetch and evaluate an ESM module.
نقاط البداية
تقدم حزمة react-dom نقطتي بداية إضافيتين:
- تحتوي
react-dom/clientعلى وظائف لتصيير مكونات React في جانب العميل (في المتصفح). - تحتوي
react-dom/serverعلى وظائف لتصيير مكونات React في الخادم.
وظائف ملغاه
- تجد
findDOMNodeأقرب عنصر DOM يتوافق مع مثيل مكونclass. - تقوم
hydrateبتركيب شجرة في DOM التي تم إنشاؤها من HTML الذي تم تصييره في الخادم. مهجور لصالحhydrateRoot. - تقوم
renderبتركيب شجرة في DOM. مهجور لصالحcreateRoot. - تقوم
unmountComponentAtNodeبإلغاء تركيب شجرة من DOM. مهجور لصالحroot.unmount().