Sections

FBRenderSectionComponent

As with Render Components in ComponentKit, Render Sections should inherit from a render specific class:FBRenderSectionComponent instead of FBSectionComponent.

Structure

The FBRenderSectionComponent base class is quite simple and most of the time you should just inherit to gain automatic changeset computation out of the box.

Interface

#import <FBSectionComponentKit/FBRenderSectionComponent.h>
@class FBAwesomeRenderSectionComponentConfiguration;
@interface FBAwesomeRenderSectionComponent : FBRenderSectionComponent
+ (instancetype)newWithConfiguration:(FBAwesomeRenderSectionComponentConfiguration *)configuration;
@end

Constructor

When the object gets initialized you need to make sure to compute and store the properties required to return an instance of your component on-demand whenever the render method is called.

@implementation FBAwesomeRenderSectionComponent {
FBAwesomeRenderSectionComponentConfiguration _configuration;
}
+ (instancetype)newWithConfiguration:(FBAwesomeRenderSectionComponentConfiguration *)configuration
{
auto const sc = [super new];
if (sc) {
sc->_configuration = configuration;
}
return sc;
}

Render method

This method is called by the underlying infrastructure whenever the component needs to be (re)generated. Your implementation would usually use the values previously stored by the initializer.

- (FBSectionComponent *)render:(id)state
{
return [FBSectionComponent newWithModel:_configuration context:nil];
}