There are many fully cross-platform modules in React Native core and the third-party module ecosystem, but sometimes we simply need to support different behaviors on different platforms. A great way to diverge implementations for each platform is using platform overrides for modules.
The React Native CLI windows
command generates a Windows-specific app entry point, App.windows.js
. We moved this to src/App.windows.tsx
to prevent an error that would have occurred before we linked the react-native-camera
dependency. This file can now be deleted, so we use the same code
In Lesson 5, we abstracted the image recognition for the react-native-tensorflow
package logic into a module, ImageRecognizer
. Stub out the implementation for Windows in a platform module override (i.e., ImageRecognizer.windows.ts
).
export default class ImageRecognizer
{
constructor(options)
{
}
recognize(data)
{
return Promise.reject('not implemented');
}
}
- A working camera app that generates the "not implemented" error when taking a photo.