5.0.0 • Published 4 months ago

filestack-react v5.0.0

Weekly downloads
19,484
License
MIT
Repository
github
Last release
4 months ago

Table of Contents

Overview

filestack-react is a wrapper on filestack-js sdk which allow you to integrate with Filestack service in just a few lines of code. Almost all you can do with filestack-js you can do with this component.

Usage

Install it through NPM

npm install filestack-react

then just insert into your app

import { PickerOverlay } from 'filestack-react';

<PickerOverlay
  apikey={YOUR_API_KEY}
  onSuccess={(res) => console.log(res)}
  onUploadDone={(res) => console.log(res)}
/>

Props

KeyTypeRequiredDefaultDescription
apikeyStringtrueFilestack api key
clientOptionsObjectfalsehttps://filestack.github.io/filestack-js/interfaces/clientoptions.html
pickerOptionsObjectfalsehttps://filestack.github.io/filestack-js/interfaces/pickeroptions.html
@deprecated onSuccessFunctionfalseresult => console.log(result)A function to be called after successful completed action
onUploadDoneFunctionfalseresult => console.log(result)Called when all files have been uploaded
onErrorFunctionfalseerror => console.error(error)A function to be called when error occurs
onErrorFunctionfalseerror => console.error(error)A function to be called when error occurs

Examples

Render basic Overlay Picker

<PickerOverlay apikey='YOUR_APIKEY'/>

Render basic Inline Picker

<PickerInline apikey='YOUR_APIKEY'/>

Render basic Drop Pane Picker

<PickerDropPane apikey='YOUR_APIKEY'/>

Show picker directly and embed it inside specific container

<PickerInline apikey='YOUR_APIKEY'><div className="your-container"></div></PickerInline>

filestack-js Client

If you need to use Client just try

import { client } from 'filestack-react';

SSR

If you need to use filestack-react with SSR project or site generators like Gatsby check some workarounds in this issues issue57 issue65

Migration from 3.x.x and 4.x.x

3.x.x4.0.0Comment
apikeyapikey
actionOptionspickerOptionsWe want to be consistent with other filestack libs
clientOptionsclientOptions
onSuccessonSuccess
onErroronError
N/AchildrenChildren prop will be used now in case you'll want to use specific container
actionN/ADefault picker action will be 'pick' always
fileN/ARemoved
sourceN/ARemoved
customRenderN/ARemoved, from now on clients will be responsible for rendering
componentDisplayModeN/ARemoved, from now on clients will be responsible for rendering

Migration from 1.x.x and 2.x.x

One of the changes introduced in the new version are rethinked props that the component accepts, so that the use of the component is as straightforward as possible. Below you will find information about what happened to each of the options available in 2.x.x :

2.x.x3.0.0Comment
apikeyapikey
modeaction
optionsactionOptionsWe want to emphasize that this option is associated with 'action'
preloadN/ANow, component is at default preloading necessary js assets, styles, images
filefile
onSuccessonSuccess
onErroronError
options.handlesourceHandle or url used by specific action is now stored in separate prop
options.urlsourceHandle or url used by specific action is now stored in separate prop
securityclientOptions.securityOptions used to initialize filestack client are now grouped in ‘clientOptions’
buttonTextcomponentDisplayMode.customTextUse componentDisplayMode option (see examples)
buttonClasscomponentDisplayMode.customClassUse componentDisplayMode option (see examples)
cnameclientOptions.cnameOptions used to initialize filestack client are now grouped in ‘clientOptions’
sessionCacheclientOptions.sessionCacheOptions used to initialize filestack client are now grouped in ‘clientOptions’
rendercustomRender
childrenN/AUse customRender instead

Live demo

Check demo at codepen https://codepen.io/Filestack/pen/KEpVdR - needs to be updated for 4.0 version

Development

All components are located inside src/picker/

After you add some changes just type

npm run build

Be sure that your change doesn't break existing tests and are compatible with linter

npm run test

Documentation

You can find info about available options for actions (Client class methods) in https://filestack.github.io/filestack-js/

Contribution

Any your contributions or ideas are more than welcome. Please consider that we follow the conventional commits specification to ensure consistent commit messages and changelog formatting.

Future

Current ideas:

  • Better support for SSR, static site generator and isomorphic apps
5.0.0

4 months ago

4.0.1

3 years ago

4.0.0

3 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.3.9

6 years ago

1.3.8

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.1.2

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.9.7

7 years ago