FingerprintJS Pro Wrapper for React Single Page Applications (SPA)

Overview

FingerprintJS

CI badge Current NPM version Monthly downloads from NPM MIT license Discord server

FingerprintJS Pro React

FingerprintJS Pro React is an easy-to-use React library for FingerprintJS Pro. This package works with FingerprintJS Pro, it is not compatible with open-source FingerprintJS. You can learn more about the difference between FingerprintJS Pro and open-source FingerprintJS in the official documentation.

Table of contents

Installation

Using npm:

npm install @fingerprintjs/fingerprintjs-pro-react

Using yarn:

yarn add @fingerprintjs/fingerprintjs-pro-react

Getting started

In order to identify visitors, you'll need a FingerprintJS Pro account (you can sign up for free). You can learn more about API keys in the official FingerprintJS Pro documentation.

  1. Wrap your application (or component) in FpjsProvider. You can specify multiple configuration options.
    Set a region if you have chosen a non-global region during registration. Please refer to the Regions page.
// src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { FpjsProvider } from '@fingerprintjs/fingerprintjs-pro-react';
import App from './App';

ReactDOM.render(
  <FpjsProvider
    loadOptions = {{
      apiKey: 'your-fpjs-public-api-key'
    }}
  >
    <App />
  </FpjsProvider>,
  document.getElementById('app')
);
  1. Use the useVisitorData hook in your components to perform visitor identification and get the data.
// src/App.js
import React from 'react';
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'

function App() {
  const {
    isLoading,
    error,
    data,
  } = useVisitorData();

  if (isLoading) {
    return <div>Loading...</div>;
  }
  if (error) {
    return <div>An error occured: {error.message}</div>;
  }

  if (data) {
    // perform some logic based on the visitor data
    return (
      <div>
        Welcome {data.visitorFound ? 'back' : ''}!
      </div>
    );
  } else {
    return null;
  }
}

export default App;

The useVisitorData hook also returns a getData method which can make an API call on your command.

// src/App.js
import React, { useState } from 'react';
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'

function App() {
  const {
    isLoading,
    error,
    getData,
  } = useVisitorData({tag: 'subscription-form'}, { immediate: false });
  const [email, setEmail] = useState('')

  if (isLoading) {
    return <div>Loading...</div>;
  }
  if (error) {
    return <div>An error occured: {error.message}</div>;
  }

  return (
    <div>
      <form
        onSubmit={(e) => {
          e.preventDefault()
          getData().then((data) => {
            if (data) {
              // do something with the visitor data
              // for example, append visitor data to the form data to send to your server
              console.log(data)
            }
          })
        }}
      >
        <label htmlFor='email'>Email:</label>
        <input
          id='email'
          type='email'
          name='email'
          required
          value={email}
          onChange={(e) => setEmail(e.currentTarget.value)}
        />
        <button type='submit'>Subscribe</button>
      </form>
    </div>
  );
}

export default App;

See the full code example in the examples folder.

Caching strategy

⚠️ WARNING If you use data from extendedResult, please pay additional attention to caching strategy.

FingerprintJS Pro uses API calls as the basis for billing. Our best practices strongly recommend using cache to optimise API calls rate. The Library uses the SessionStorage cache strategy by default.

Some fields from the extendedResult (e.g ip or lastSeenAt) might change for the same visitor. If you need exact current data, it is recommended to pass ignoreCache=true inside getData function.

Documentation

This library uses FingerprintJS Pro agent internally. The documentation for the FingerprintJS Pro agent is available on https://dev.fingerprintjs.com/docs.

FpjsProvider props

loadOptions: FingerprintJS.LoadOptions

Options for the FingerprintJS JS Pro agent load() method. Options follow agent's initialisation properties.

cacheLocation?: CacheLocation

Defines which built-in cache mechanism the client should use. Caching options follow properties defined in fingerprintjs-pro-spa repository.

cache?: ICache

Custom cache implementation. Takes precedence over the cacheLocation property. Caching options follow properties defined in fingerprintjs-pro-spa repository.

cacheTimeInSeconds?: number

Duration in seconds for which data is stored in the cache. Cannot exceed 86_400 (24h) because caching data for longer than 24 hours can negatively affect identification accuracy. Caching options follow properties defined in fingerprintjs-pro-spa repository.

cachePrefix?: string

Custom prefix for localStorage and sessionStorage cache keys. Will be ignored if the cache is provided. Caching options follow properties defined in fingerprintjs-pro-spa repository.

Hooks

useVisitorData(getOptions, config)

useVisitorData hook performs identification requests with the FingerprintJS Pro API. The returned object contains information about loading status, errors, and visitor.

Params

  • getOptions: GetOptions<TExtended> parameter follows parameters of the FingerprintJS Pro's get function.
  • config: UseVisitorDataConfig's property immediate determines whether the getData() method will be called immediately after the hook mounts or not.

Returned object

  • getData: ({ignoreCache?: boolean}) => Promise<VisitorData> Performs identification request to server and returns visitors data.
  • isLoading: boolean Indicates getData request status.
  • data: VisitorData Contains visitors data requested after getData() call.
  • error: Error Error information in case the request failed.

Support and feedback

For support or to provide feedback, please raise an issue on our issue tracker. If you require private support, please email us at [email protected]. If you'd like to have a similar React wrapper for the open-source FingerprintJS, consider raising an issue in our issue tracker.

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Comments
  • Synchronous env detection via `<WithEnvironment />`

    Synchronous env detection via ``

    Resolves #59

    This PR implements <WithEnvironment /> component which can be used to detect the current env. It has an improved check for Preact that relies on the number of arguments passed down to render() and it doesn't require a re-render. I haven't wired it up with the rest of the code yet (I plan to do that in the next PR), as there are some caveats we need to discuss first:

    1. It uses a class keyword which could potentially increase the bundle size since we target es5 in the config. I don't think it would create any issues though, but proper bundle analysis is probably required
    2. There is no proper test to check if the argument condition does indeed return true when rendered via Preact. I guess that's the responsibility of a more higher-level integration test, ideally covered by <FpjsProvider /> tests, but I didn't want to overload the PR and wanted to make it more atomic.
    released 
    opened by molefrog 10
  • Allow `getData` to throw errors, allow multiple failed requests, error messages doesn't match library constants

    Allow `getData` to throw errors, allow multiple failed requests, error messages doesn't match library constants

    Hello I've been getting some Client timeout validations for some users that try to log in from a mobile with low signal where in those cases I've setted up fallback to other types of security validations the problem is that the only way to handle those errors is from the error coming from useVisitorData I want to be able to handle those errors on a try/catch clause using getData instead.

    Another issue that I've found is that the errors defined in @fingerprintjs/fingerprintjs-pro do not match exactly the errors coming from the API

    import { ERROR_CLIENT_TIMEOUT } from '@fingerprintjs/fingerprintjs-pro';
    

    The error message that is returned from the your service has this Error: prefixed on every error so its not possble to handle those errors like you mention in your documentation

    ERROR_CLIENT_TIMEOUT !== "Error: Clear timeout"

    Finally for my use case where I use getData when the user tries to log in once I get an invalid response it won't let me fetch another response unless I unmount the hook or refresh the page, I should be able to use getData and get responses from it on demand, not only once per component mounted.

    Here is an screencast of the issue:

    https://user-images.githubusercontent.com/18445985/198707059-fca05c66-7170-4e9f-a891-b1b6e249f827.mov

    released 
    opened by inrumi 6
  • A simpler way to detect Preact

    A simpler way to detect Preact

    Hi! I was doing some digging into the source code and I noticed that the current approach of detecting Preact environment creates some constraints in the other parts of the library. If we just had some simpler, ideally synchronous way of Preact detection we would have:

    1. Avoided having an invisible span rendered by <FpjsProvider />. While it doesn't seem like a big deal, there could be some clients that expect the library doesn't produce any html, and could rely on some exotic CSS in their apps like body > div.
    2. Simplified the client initialization and loading logic and potentially avoided extra rendering at the startup.

    I don't have a definitive answer yet, however I have compiled a list of tricks that might work here:

    1. A more hacky and less stable option: ctx = createContext({}); isPreact = ctx._id || ctx.__c (the property name is _id in the source code, but it becomes __c after mangling). Pros: works for Preact starting from 10.0.0 (the first release where hooks became generally available), doesn't require any additional component, completely synchronous. Cons: it's implementation specific and might break in the future.
    2. Check the number of arguments passed down to class component's render(). Preact always has two agruments. Pros: works in both 8.x and 10.x, it's an official documented difference and it is less likely to be changed in the current release Cons: it is not completely synchronous, however it doesn't output an html element.

    Let me know what you think, Cheers.

    enhancement released 
    opened by molefrog 5
  • Breaks navigation in Next.js

    Breaks navigation in Next.js

    I noticed that adding this library to an existing Next.js project according to the docs breaks the navigation (particularily next/link) on my entire site.

    While trying to find out if this was due to my project, I extended the Next.js example in examples/next with a new test.tsx page and a link in index.tsx and could successfully reproduce the issue.

    Clicking on the link changes the URL but doesn't navigate. This seems to have to do with the fact that FPJS is integrated in the _app.tsx layout. When I tried adding the provider on a single page only, things worked as expected.

    How to reproduce?

    Add test.tsx to examples/next/pages:

    import type { NextPage } from 'next'
    
    const Test: NextPage = () => <h1>test</h1>
    
    export default Test
    

    Add link to examples/next/pages/index.tsx:

    import Link from 'next/link'
    
    <Link href='/test'>
      <a>test</a>
    </Link>
    

    Click new link.

    released 
    opened by davidknezic 3
  • Dont working in Firefox

    Dont working in Firefox

    I installed on NextJS, the latest version, it works great for google Chmmo, Vivaldi, Brave and Opera, but on FireFox of the following error:

    error.message FPJSAgentError: Error: Network connection error And: Requisição cross-origin bloqueada: A diretiva de mesma origem (same origin policy) impede a leitura do recurso remoto em https://api.fpjs.io/?ci=js/3.6.1 (motivo: falha na requisição CORS). Código de status: (null).

    image

    opened by JonhnyDev 3
  • Some of options supported in SPA library are ignored

    Some of options supported in SPA library are ignored

    Because we memoize our getOptions:

    const { extendedResult, timeout, tag, linkedId } = getOptions ?? {}
    const memoizedOptions = useMemo(
      () => ({ extendedResult, timeout, tag, linkedId }),
      [extendedResult, timeout, tag, linkedId]
    )
    

    we skip the new products field recently introduced in our JavaScript Agent.

    bug released released on @test 
    opened by TheUnderScorer 2
  • Fix env detector script not detecing env on component mount

    Fix env detector script not detecing env on component mount

    There was an issue, where the client could be initialized before we detected env, thus we ended up never really using this data.

    This PR attempts to fix this issue by rewriting logic how we initialize our client.

    released released on @test 
    opened by TheUnderScorer 2
  • build(deps): bump moment from 2.29.3 to 2.29.4

    build(deps): bump moment from 2.29.3 to 2.29.4

    Bumps moment from 2.29.3 to 2.29.4.

    Changelog

    Sourced from moment's changelog.

    2.29.4

    • Release Jul 6, 2022
      • #6015 [bugfix] Fix ReDoS in preprocessRFC2822 regex
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies released released on @test 
    opened by dependabot[bot] 2
  • chore(deps): bump ejs from 3.1.6 to 3.1.8 in /examples/spa

    chore(deps): bump ejs from 3.1.6 to 3.1.8 in /examples/spa

    Bumps ejs from 3.1.6 to 3.1.8.

    Release notes

    Sourced from ejs's releases.

    v3.1.8

    Version 3.1.8

    v3.1.7

    Version 3.1.7

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 2
  • Rename the

    Rename the "token" option to "apiKey"

    The PR depends on https://github.com/fingerprintjs/fingerprintjs-pro-spa/pull/8. Please update the SPA dependency of this library after you merge and publish the SPA PR.

    This is not a breaking change because the token option still works.

    opened by Finesse 2
  • build(deps): bump loader-utils from 2.0.3 to 2.0.4 in /examples/spa

    build(deps): bump loader-utils from 2.0.3 to 2.0.4 in /examples/spa

    Bumps loader-utils from 2.0.3 to 2.0.4.

    Release notes

    Sourced from loader-utils's releases.

    v2.0.4

    2.0.4 (2022-11-11)

    Bug Fixes

    Changelog

    Sourced from loader-utils's changelog.

    2.0.4 (2022-11-11)

    Bug Fixes

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies released 
    opened by dependabot[bot] 1
  • build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /examples/preact

    build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /examples/preact

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /examples/spa

    build(deps): bump decode-uri-component from 0.2.0 to 0.2.2 in /examples/spa

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • build(deps): bump decode-uri-component from 0.2.0 to 0.2.2

    build(deps): bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Updating state in `useVisitorData` might cause a warning in React < 18

    Updating state in `useVisitorData` might cause a warning in React < 18

    Hi! Prior to React 18 there was a warning that the library would show if you tried to set state in already unmounted component. Luckily, in the newest version they made this less strict so that application developers don't have to guard state updates with any additional checks.

    There are three places where we update the state in an asynchronous function inside the useVisitor hook. Even though it's not the case anymore, since this is a library, there could be clients who still use React 17 or earlier, it would be nice if we could prevent any warnings from happening.

    The fix can be really straight forward like:

    const isComponentUnmounted = useRef<boolean>(false)
    
    useEffect(() => {
      return () => isComponentUnmounted.current = true
    }, [])
    
    // inside an async func
    if(isComponentUnmounted.current) return
    setState(...)
    
    opened by molefrog 0
  • Add useful example for the `getData` method

    Add useful example for the `getData` method

    In the example below we show how to call the getData method but don't afford any useful scenarios of what we can do with that data. We need to add a better scenario to the documentation.

    <form
      onSubmit={(e) => {
        e.preventDefault()
        getData().then((data) => {
          if (data) {
            // do something with the visitor data
            // for example, append visitor data to the form data to send to your server
            console.log(data)
          }
        })
      }}
    >
    
    opened by ilfa 0
Releases(v2.2.0)
Owner
FingerprintJS
Fraud detection API for the Internet
FingerprintJS
This restaurant project is a SPA (single-page application) website. The user can navigate between the home, menu and contact page. I used the MealDB API to display some menu items.

Fresh Cuisine This restaurant project is from the Odin Project and it is a SPA (single-page application) website. The user can navigate between the ho

Virag Kormoczy 7 Nov 2, 2022
Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read a random math-related quote. Build with React.js

Math Magicians Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations an

Kyrillos Hany 9 Mar 23, 2022
A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ💯

A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ??

Reem janina 7 May 31, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read random math-related quotes. Its built using react

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations a

Charles Gobina 5 Feb 23, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

math-magicians A Single Page App (SPA) that allows users to Make simple calculations and read a random math-related quote. "Math magicians" is a websi

Temitope Ogunleye 3 Feb 21, 2022
This project is a single-page application (SPA) about Booklist in which you can add your favorite books.

AWESOME BOOKS This website Awesome Books Library provides users a convenient way to keep track of their books or reading lists. Users can add and remo

Omar Salem 10 Feb 25, 2022
Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

Math Magicians. Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations

Mithlesh kumar 5 Mar 29, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations.

Emmanuel Allan 6 Jun 27, 2022
"Math Magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random maths-related quote.

Project Name : Math Magicians "Math Magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simp

Amrendra K 8 May 29, 2022
Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

react-math-magicians React Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: - - Make simpl

null 5 May 27, 2022
Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculation.

Math Magians Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculation. Live

Nedjwa Bouraiou 8 Sep 6, 2022
A SPA (Single Page Application) that can track your books on your browser! Made with ES6 modules,JavaScript, HTML 5 and CSS 3.

Awesome-Books-project Recreate awesome book app using ES6 syntax and modules. Built With HTML CSS Javascript Live Demo (if available) Live Demo Link G

Youta Lactio Christabelle 7 Jul 14, 2022
Module 03 project: Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculations and Read a random math-related quote.

Math-magicians Math magicians is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to Make simple calculations an

Basir Mohammadi 14 Sep 26, 2022
Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations and Read a random math-related quote.

Capstone project / FilmTube This is the final project of the moduel 2. we build a series page using an API to display all the series on the main page

Amalia Gomez Moro 5 Aug 23, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations. Read a random math-related quote.

ONLINE MATH CALCULATOR USING REACT "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make

Natasha  Tatenda Chirombe 6 Aug 24, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read a random math-related quote.

Math magicians "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to: Make simple calculations

Tiago Lelinski Marin 8 Aug 26, 2022