getCurrentPages()

Requires:
@ray-js/ray≥0.2.0

Description

Get the current page stack. Returns an array of page objects; the first element is the home page and the last element is the current page.

Parameters

None

Return Value

Type: PageInstance[]
Page stack array; each element is a PageInstance object

Examples

Basic usage

import React from 'react';
import { View, Button, getCurrentPages } from '@ray-js/ray';

export default function Home() {
  const handleGetPages = () => {
    const pages = getCurrentPages();
    console.log('Current page stack length:', pages.length);
    console.log('Current page:', pages[pages.length - 1]);

    pages.forEach((page, index) => {
      console.log(`Page ${index}:`, page.route);
    });
  };

  return (
    <View style={{ padding: 20 }}>
      <Button onClick={handleGetPages}>Get page stack</Button>
    </View>
  );
}