i try to implement a react-native-canvas into my app.
On entering the screen that contains the canvas, in the version generated with react-native run-ios
, i receive following error:
Invariant Violation: requireNativeComponent: "RNCWKWebView" was not found in the UIManager.
This error is located at:
in RNCWKWebView (at WebView.ios.js:297)
in RCTView (at View.js:45)
in View (at WebView.ios.js:300)
in WebView (at Canvas.js:148)
in RCTView (at View.js:45)
in View (at Canvas.js:147)
in Canvas (at LapDetails.tsx:47)
in RCTView (at View.js:45)
in View (at LapDetails.tsx:38)
in LapDetails (at ComponentWrapper.js:29)
in WrappedComponent (at renderApplication.js:34)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:33)
getNativeComponentAttributes
a90c6db6-7158-4812-8a98-ea48c1a859f3:49643:5
<unknown>
a90c6db6-7158-4812-8a98-ea48c1a859f3:49596:14
Object.exports.get
a90c6db6-7158-4812-8a98-ea48c1a859f3:43914:20
createInstance
a90c6db6-7158-4812-8a98-ea48c1a859f3:22099:56
completeWork
a90c6db6-7158-4812-8a98-ea48c1a859f3:28453:34
completeUnitOfWork
a90c6db6-7158-4812-8a98-ea48c1a859f3:30472:32
performUnitOfWork
a90c6db6-7158-4812-8a98-ea48c1a859f3:30635:18
workLoop
a90c6db6-7158-4812-8a98-ea48c1a859f3:30645:30
renderRoot
a90c6db6-7158-4812-8a98-ea48c1a859f3:30716:13
Error on entring the View a second time:
Invariant Violation: View config not found for name RNCWKWebView.
This error is located at:
in RNCWKWebView (at WebView.ios.js:297)
in RCTView (at View.js:45)
in View (at WebView.ios.js:300)
in WebView (at Canvas.js:148)
in RCTView (at View.js:45)
in View (at Canvas.js:147)
in Canvas (at LapDetails.tsx:47)
in RCTView (at View.js:45)
in View (at LapDetails.tsx:38)
in LapDetails (at ComponentWrapper.js:29)
in WrappedComponent (at renderApplication.js:34)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:33)
Object.exports.get
ReactNativeViewConfigRegistry.js:94:6
createInstance
ReactNativeRenderer-dev.js:3946:49
completeWork
ReactNativeRenderer-dev.js:13385:25
completeUnitOfWork
ReactNativeRenderer-dev.js:15892:25
performUnitOfWork
ReactNativeRenderer-dev.js:16103:11
workLoop
ReactNativeRenderer-dev.js:16115:23
renderRoot
ReactNativeRenderer-dev.js:16219:6
performWorkOnRoot
ReactNativeRenderer-dev.js:17198:6
performWork
ReactNativeRenderer-dev.js:17099:6
Now the interesting part. When i run the app fully build from XCode i can enter the view and the canvas is displayed.
I tried automatic relinking, reinstalls, different devices and manual relinking because those where the most mentioned fixes for issues of that type. But nothing changes the outcome for the version generated with react-native run-ios
.
I am pretty sure the problem is somewhere with my linking of react-native-webview but i can't figure out where and i basically did everything the installation guides mention...
my android project is currently broken so i can't provide additional information for android behavior.
In case you wondering this is the view:
import React, { Component } from 'react';
import Canvas from 'react-native-canvas';
class App extends Component {
handleCanvas = (canvas) => {
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'purple';
ctx.fillRect(0, 0, 100, 100);
}
render() {
return (
<Canvas ref={this.handleCanvas}/>
);
}
}
Usually problems like this are caused by incorrect linked native dependencies. You can try react-native link <package name>
, but here that didn't seem to be the case, because the fully build app worked.
Some old build files where interfering with the development builds and i solved this problem by deleting the whole project and cloning it with git again. to do this without git you would need to delete all your build-files in android/ and ios/ and delete your node_modules (this doesn't has to be done but for safety sake).
If you still encounter problems after this you might consider that the first problem is representing your case, especially if you can't even compile the production build.