Files
react-native/ReactCommon/react/renderer/components/text/ParagraphEventEmitter.h
T
Samuel Susla 412fc7d324 Prevent calling onTextLayout with the same value
Summary:
Changelog: [internal]

In D23648430 (https://github.com/facebook/react-native/commit/a315e4cd30e4b8da841f587650146a62c868f67d) I made a mistake. I prevented calling `onTextLayout` unless there are attachments in the component. It fixed the problem because I unintentionally prevented `onTextLayout`  to be called. Therefore, changes from D23648430 (https://github.com/facebook/react-native/commit/a315e4cd30e4b8da841f587650146a62c868f67d) need to be reverted.

To prevent infinite loop in `onTextLayout`, ParagraphEventEmitter checks if `linesMeasurements` have changed before dispatching it to JS.

Reviewed By: shergin

Differential Revision: D23782717

fbshipit-source-id: 0e84ae4f46d79ce0cf4c7340cd32be6f562ae179
2020-09-20 08:18:55 -07:00

29 lines
710 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/components/view/ViewEventEmitter.h>
#include <react/renderer/textlayoutmanager/TextMeasureCache.h>
namespace facebook {
namespace react {
class ParagraphEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
void onTextLayout(LinesMeasurements const &linesMeasurements) const;
private:
mutable std::mutex linesMeasurementsMutex_;
mutable LinesMeasurements linesMeasurementsMetrics_;
};
} // namespace react
} // namespace facebook