You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- (void)updateState:(const facebook::react::State::Shared &)state oldState:(const facebook::react::State::Shared &)oldState
{
_view.readyToRender = oldState != nullptr; // Skip render until measurements sent to shadow node.
_state = std::static_pointer_cast<const PdfViewShadowNode::ConcreteState>(state);
[_view measurePdf]; // Sends results to `_state->updateState()`
[superupdateState:state oldState:oldState];
}
I hacked a guard that prevents the view from rendering until the second call to updateState(). Without this, the view will first render at the wrong dimensions, then the measurements sent to the shadow node will trigger a re-layout, and the view will re-render at the correct dimensions. So, I essentially skip insertion and wait for the second update before rendering. But this feels like it is depending on an implementation detail, not normal APIs.
Is this really the best way of handling shadow nodes with layout computed from props? This did not occur for me on the old architecture.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
https://github.com/alpha0010/react-native-pdf-viewer/blob/b3e25ac5f4a035d80673d23efa4a556ebcafe82f/ios/PdfView.mm#L83
I hacked a guard that prevents the view from rendering until the second call to
updateState(). Without this, the view will first render at the wrong dimensions, then the measurements sent to the shadow node will trigger a re-layout, and the view will re-render at the correct dimensions. So, I essentially skip insertion and wait for the second update before rendering. But this feels like it is depending on an implementation detail, not normal APIs.Is this really the best way of handling shadow nodes with layout computed from props? This did not occur for me on the old architecture.
Beta Was this translation helpful? Give feedback.
All reactions