1.0.49 • Published 3 years ago

feathery-react-client-sdk v1.0.49

Weekly downloads
18
License
MIT
Repository
github
Last release
3 years ago

feathery-react-client-sdk

React SDK for Feathery

NPM JavaScript Style Guide

Install

You can use yarn or npm.

Yarn

yarn add feathery-react-client-sdk

npm

npm install --save feathery-react-client-sdk

API Guide

The following is an example React component that uses the Feathery library.

import { Feathery } from 'feathery-react-client-sdk';

function App() {
  // Initialize Feathery to Peter
  Feathery.init('apiKey', 'peter@feathery.tech');

  const [fields, setFields] = useState({});
  useEffect(() => {
    // Access the fields that Peter filled out in the form
    Feathery
      .fetchFields()
      .then(fields => {setFields(fields)});
  }, [])

  // Show the `onboarding` Feathery form
  return <Feathery.Form
    formKey='onboarding'
    onSubmit={(fieldInfo, stepNumber, lastStep) => store(fieldInfo)}
  />
}

Feathery.init

Function that initializes the Feathery library to the correct user and auth info. This is necessary before using the rest of the API and can be called multiple times.

Parameters

  1. userKey\ Type: string\ Unique ID of the user who is accessing Feathery. This can be anything as long as it's unique per user.
  2. apiKey\ Type: string\ Feathery API Key. This authorizes the library to communicate with Feathery servers.

<Feathery.Form>

Initialize this component in your React app at the location where you want a Feathery form to appear. It renders an HTML form element.

Props

  1. formKey\ Type: string\ ID of the Feathery form to display
  2. onSubmit(fieldInfo, stepNumber, lastStep)\ Type: function\ Callback function to access user-submitted form information. It's called every time the user submits a step of the form.\ Parameters (in order):
    • fieldInfo: An array of the form [{name: <fieldName>, key: <fieldKey>, type: <fieldType>, value: <fieldValue>}].\ For example, [{name: 'How old are you?', key: 'age', type: 'integer_field', value: 21 }].\ Note that if the field is of file_upload type, the value will be a File object.
    • stepNumber: An int that's the zero-indexed step number being submitted.
    • lastStep: A boolean that is True when the step being submitted is the last step the user needs to complete.

Feathery.fetchFields

Function that returns a Promise containing a map of user field inputs of the form {fieldKey: fieldValue}.

If the user doesn't exist, the map will be empty. If the user doesn't have a value for a particular field, the field value will be null.

This method is implemented as a singleton, so there will only be one global source of data.

License

MIT © Peter Dun

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago