Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chayns-hooks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chayns-hooks

Makes the chayns-js API easier to consume in your react components.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

chayns-hooks

Welcome to chayns-hooks 👋

Version Maintenance License: MIT Twitter: leodriesch

Makes the chayns-js API easier to consume in your react components.

Install

yarn add chayns-hooks

or

npm install chayns-hooks

Please note that this needs the chayns-js API to be available on the window object and chayns.ready should be finished.

The instructions for how to get started with the chayns-js API can be found here.

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Leo Driesch.
This project is MIT licensed.

chayns-hooks

Index

Interfaces

Type aliases

Functions

Type aliases

PossiblyEmptyString

Ƭ PossiblyEmptyString: string


VisibilityEffect

Ƭ VisibilityEffect: function

A function that can respond to the change of the visibility status of your page.

param This parameter expresses wether the last visibility status update indicates that the page is now shown or not.

Type declaration:

▸ (isShown: boolean): void

Parameters:

NameType
isShownboolean

Functions

useAdminMode

useAdminMode(): AdminModeHookReturnValue

Using this hook will subscribe your component to the current state of the admin mode.

Returns: AdminModeHookReturnValue

An object that can be destructed to get access to the current status of the admin mode and functions to manually activate or deactivate the admin mode.


useChaynsUser

useChaynsUser(): ChaynsUser

Returns the current user object and will update the user on access token change.

Returns: ChaynsUser

The user object for the currently logged in user.


useVisibilityEffect

useVisibilityEffect(effect: VisibilityEffect): void

This hook can execute side effects when the visibility status of your page changes.

Parameters:

NameTypeDescription
effectVisibilityEffectThis function will be called when the visibility changes and can respond to the change by executing side effects. Consider using useCallback with this function, otherwise the listener will be attached and detached on every render.

Returns: void

Nothing. Use it similarly to useEffect.

Interface: AdminModeHookReturnValue

Hierarchy

  • AdminModeHookReturnValue

Index

Properties

Properties

activateAdminMode

activateAdminMode: function

Calling this function will activate the admin mode, if it is currently inactive. Otherwise it will do nothing.

Type declaration:

▸ (): void


deactivateAdminMode

deactivateAdminMode: function

Calling this function will deactivate the admin mode, if it is active. Otherwise it will do nothing.

Type declaration:

▸ (): void


isAdminMode

isAdminMode: boolean

Indicates if the user is currently in admin mode or not.

Interface: ChaynsUser

Hierarchy

  • ChaynsUser

Index

Properties

Properties

adminMode

adminMode: boolean

Wether the admin mode is currently active or not. Be careful with this, as it might be stale. Use the useAdminMode hook when you need access to this information.


Optional firstName

firstName? : undefined | string


groups

groups: UACGroup[]

This contains the groups for a user. Will be an empty array if the user is not logged in.


id

id: number

The user-id.for the currently logged in user. Careful: If no user is logged in, this will be 0 (not null or undefined)


isAdmin

isAdmin: boolean


isAuthenticated

isAuthenticated: boolean


Optional lastName

lastName? : undefined | string


name

name: PossiblyEmptyString

The name for the currently logged in user. Careful: If no user is logged in, this value will be an empty string.


personId

personId: PossiblyEmptyString

The person-id for the currently logged in user. Careful: If no user is logged in, this value will be an empty string.


tobitAccessToken

tobitAccessToken: PossiblyEmptyString

The access token for the currently logged in user. Careful: If no user is logged in, the value will be an empty string.

Interface: UACGroup

Hierarchy

  • UACGroup

Index

Properties

Properties

id

id: number


isActive

isActive: boolean


Optional isSystemGroup

isSystemGroup? : undefined | false | true


Optional name

name? : undefined | string

FAQs

Package last updated on 15 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc