Files
react-native/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h
T
Samuel Susla 2cda4f71b6 Simplify createInitialState interface (#37069)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37069

changelog: [internal]

To create initial C++ state, nothing beside props is needed from `ShadowNodeFragment` and this diff removes it.

It makes creation of state easier as we will no longer need to check if props are nullptr.

Reviewed By: mdvacca

Differential Revision: D45183692

fbshipit-source-id: 81ab8eb3c57f6ff64aaed7c5b395555dce6b60b2
2023-04-26 05:50:49 -07:00

47 lines
1.4 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and 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/scrollview/ScrollViewEventEmitter.h>
#include <react/renderer/components/scrollview/ScrollViewProps.h>
#include <react/renderer/components/scrollview/ScrollViewState.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/core/LayoutContext.h>
namespace facebook::react {
extern const char ScrollViewComponentName[];
/*
* `ShadowNode` for <ScrollView> component.
*/
class ScrollViewShadowNode final : public ConcreteViewShadowNode<
ScrollViewComponentName,
ScrollViewProps,
ScrollViewEventEmitter,
ScrollViewState> {
public:
using ConcreteViewShadowNode::ConcreteViewShadowNode;
static ScrollViewState initialStateData(
Props::Shared const &props,
ShadowNodeFamilyFragment const &familyFragment,
ComponentDescriptor const &componentDescriptor);
#pragma mark - LayoutableShadowNode
void layout(LayoutContext layoutContext) override;
Point getContentOriginOffset() const override;
private:
void updateStateIfNeeded();
void updateScrollContentOffsetIfNeeded();
};
} // namespace facebook::react