1.0.6 • Published 6 years ago

@times-stories/context v1.0.6

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
6 years ago

@times-stories/context

The React context provider for the @times-stories suite of packages

Installation

$ yarn add @times-stories/context

Usage

It is unlikely you'll ever need to use this directly, unless you're building custom page templates.

Below is an example how how this can be used to create a page with a custom navigation element (much like how @times-stories/end-page works).

import Story from "@times-stories/story";
import Page from "@times-stories/page";
import StoryContext from "@times-stories/context";

export default () => (
  <Story>
    <Page>
      {props => (
        <StoryContext.Consumer>
          {({ handlers }) => (
            <button onClick={handlers.setActivePage(1)}>
              Reset to first page
            </button>
          )}
        </StoryContext.Consumer>
      )}
    </Page>
  </Story>
);