0.9.1 • Published 2 years ago

manyways-react-context v0.9.1

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

#manyways

Running the SDK

Initialization

import ManywaysProvider from "@manyways/run";

const MyApp = ({ children }) => {
  return (
    <>
      <ManywaysRunProvider
        slug="my-slug"
        customComponents={{
          choiceWithImage: MyComponent,
        }}
        disableRender={false}
      >
        {children}
      </ManywaysRunProvider>
    </>
  );
};

Props

PropDescription
slug (required)Your Journey Slug
disableRenderThis causes the Provider not to render any components at all, ideally used when in pure headless mode
customComponentsThis is ignored if disableRender is true. Can provide a object mapped with name and value. Expects the value to be a react component. Full list of component names can be found here @todo
customComponents

All Custom components will have value and onChange props passed to them.

ChoiceWithImage Text Date DateTime Checkbox AutoComplete MapWithDynamicSource Slideshow Prose

useManyways hook

This is the main way to utilize the various methods and journey states used by manyways.

import { useManyways } from "@manyways/run";
Getters, setters and actions
NameDesc
currentNodeThe current node object from the api
currentResponseThe current user response to the current node if it exists. Will return null if unanswered
goBackTake the user to the previous node. Will return current node if the user is unable to go back
setResponseSet the current response
goForwardGo to the next node with the current response
responseHistoryAn array of response objects with node ids and responses
getResponseByNodeIDGet response for node based on nodeID
treeConfigGet tree config
journeyNodesArray of all journey nodes
localeGet the current language
setLocaleSet the current language
shareJourneyOpen the share journey panel
copyLinkCopies the link to continue later to the clipboard