Check for nullptr to prevent crash

Summary:
Changelog: [internal]

Prevent crash when casting of state to `ImageShadowNode::ConcreteState` fails. This doesn't fix root cause of the problem but stops the app from crashing.

Reviewed By: JoshuaGross

Differential Revision: D26604807

fbshipit-source-id: 17a2ead56ac68e560070ed4defd364a9d1dfd1e8
This commit is contained in:
Samuel Susla 2021-02-23 10:10:53 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 7b09eb54e7
Коммит d20b5e1481
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -83,7 +83,8 @@ using namespace facebook::react;
bool havePreviousData = oldImageState && oldImageState->getData().getImageSource() != ImageSource{};
if (!havePreviousData || newImageState->getData().getImageSource() != oldImageState->getData().getImageSource()) {
if (!havePreviousData ||
(newImageState && newImageState->getData().getImageSource() != oldImageState->getData().getImageSource())) {
// Loading actually starts a little before this, but this is the first time we know
// the image is loading and can fire an event from this component
std::static_pointer_cast<ImageEventEmitter const>(_eventEmitter)->onLoadStart();