Documentation
Base
InstaStories

InstaStories

The InstaStories component is the main component for rendering the library.

Properties

Component

PropertyTypeDescription
configConfigurationOptional configuration of the library component.
childrenReact.ReactNodeChildren elements to be rendered inside the library component (Configurable, Stories, Pages).
...eventsViewerEventsOptional callback events for component.

Events

EventTypeDescription
onOpenFunctionFunction to be called when the viewer opens/mounts.
onShowFunctionFunction to be called when the viewer starts to show.
onHideFunctionFunction to be called when the viewer starts to hide.
onCloseFunctionFunction to be called when the viewer closes/unmounts.

Configuration

You can access to this object into inner components through hook useConfig.

PropertyTypeDescription
animationAnimationThe animation type for opening state of viewer.
durationnumberThe duration of each story in milliseconds by default.
previewobjectThe configuration for the preview component.
preview.mountedbooleanMounts the preview on mounting main component.
timerobject
timer.shouldUseDefaultbooleanEnables/disables default in-built timer. When false - use supported third-party timer context to navigate between stories and pages.
timer.intervalnumber
viewerobjectThe configuration for the viewer component.
viewer.mountedbooleanMounts immediately active viewer on mounting the main component.
viewer.propsReact.DialogHTMLAttributesProps for the active viewer component.
viewer.storynumberThe index of the story was been opened only on mounted = true.

Global

PropertyTypeDescription
debugbooleanEnables debug mode.

Contexts Available

Usage

import {
  InstaStories,
  Page,
  Pages,
  Preview,
  Stories,
  Story
} from "@react-instastories/base";
 
import "@react-instastories/base/index.css";
 
export function AppStories() {
  return (
    <InstaStories>
      <Stories>
        <Story>
          <Preview>Preview Content</Preview>
          <Pages>
            <Page>Page Content</Page>
          </Pages>
        </Story>
      </Stories>
    </InstaStories>
  );
}

Demo

Default

Should Mount Configuration

StateProperty
config.preview.shouldMount
config.viewer.shouldMount

Debug mode

The debug mod will be used for all InstaStories, regardless of where debug: true was declared.

import { config } from "@react-instastories/base";
 
config.debug = true;
StateProperty
config.debug