File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,14 +35,14 @@ - (instancetype)initWithFrame:(CGRect)frame
3535 __weak PdfView *weakSelf = self;
3636 _view.onPdfError = ^(NSString *message) {
3737 PdfView *strongSelf = weakSelf;
38- if (strongSelf) {
38+ if (strongSelf && strongSelf-> _eventEmitter ) {
3939 static_cast <const PdfViewEventEmitter &>(*strongSelf->_eventEmitter )
4040 .onPdfError ({[message UTF8String ]});
4141 }
4242 };
4343 _view.onPdfLoadComplete = ^(NSInteger width, NSInteger height) {
4444 PdfView *strongSelf = weakSelf;
45- if (strongSelf) {
45+ if (strongSelf && strongSelf-> _eventEmitter ) {
4646 PdfViewEventEmitter::OnPdfLoadComplete evt;
4747 evt.width = static_cast <int >(width);
4848 evt.height = static_cast <int >(height);
Original file line number Diff line number Diff line change @@ -290,10 +290,13 @@ public class PdfView: UIView {
290290 }
291291
292292 private func dispatchOnError( message: String ) {
293- guard let dispatcher = onPdfError else {
294- return
293+ // Queue message to give RN core a chance to init event emitters.
294+ DispatchQueue . main. async {
295+ guard let dispatcher = self . onPdfError else {
296+ return
297+ }
298+ dispatcher ( message)
295299 }
296- dispatcher ( message)
297300 }
298301
299302 private func dispatchOnLoadComplete( pageWidth: CGFloat , pageHeight: CGFloat ) {
You can’t perform that action at this time.
0 commit comments