Skip to content

Section Component

A context-providing container component that renders different types of content layouts (Grid or Banner) based on section type.

⚠️ Important: This component provides section context to child components and handles responsive styling with a maximum width of 1080px.

Usage

jsx
import { Section } from '@wlloyalty/wll-react-native-sdk'

const section = {
  type: 'GRID',
  name: 'Featured Content',
  tiles: [...],
  priority: 5,
}

function MyComponent() {
  return <Section section={section} />
}

Props

NameTypeRequiredDescription
sectionTSectionYesSection configuration object containing layout type and content

Section Types

TypeComponentDescription
GRID<Grid />Displays tiles in a responsive grid layout
BANNER<Carousel />Shows Banner tiles in a scrollable carousel

Context

The component provides a SectionContext with the following structure:

typescript
type SectionContextType = {
  sectionData: TSection;
};

Using the Context

jsx
import { useSectionContext } from '@wlloyalty/wll-react-native-sdk'

function ChildComponent() {
  const { sectionData } = useSectionContext()
  // Access section data here
}

Section Configuration Object

PropertyTypeDescription
idstringUnique identifier
namestringSection name
type'GRID' | 'BANNER'Layout type
titlestringOptional display title
descriptionstringOptional section description
tilesTile[]Array of tile configurations
prioritynumberSection display priority
activebooleanSection visibility flag
pointsMultipliernumberOptional points multiplier
pointsPrefixstringOptional points prefix text
pointsSuffixstringOptional points suffix text
localestringSection locale

Styling

The component applies responsive styles with:

  • 100% width
  • Maximum width of 1080px
  • Automatic horizontal margins
  • Responsive bottom margin (40px on mobile/tablet, 60px on desktop)

Error Handling

  • Logs warning for unknown section types
  • Throws error if context is used outside provider

States

  • Grid: Displays content in grid layout
  • Banner: Displays content in carousel
  • Unknown Type: Renders nothing with console warning

Released under the MIT License.