Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
dialog-manager-react
Advanced tools
Readme
npm install dialog-manager-react
Checkout the demo
Create a file in your project for defining your dialogs
DialogManager.tsx
import { lazy } from 'react'
import { createDialogWrapper } from "dialog-manager-react";
const Dialogs = {
'loginDialog': Dialog, // Use functional components
'loginDialog2': lazy(() => import('./LoginDialog')) // Use lazy loaded components
};
const { DialogManager, useDialogs } = createDialogWrapper(Dialogs);
export {
DialogManager,
useDialogs
}
Now in the root of the project you'll need to set up the DialogManager
index.tsx
import { DialogManager } from './DialogManager'
ReactDOM.render(
<DialogManager>
<App />
</DialogManager>,
document.getElementById('root') as HTMLElement
);
Create a Dialog
Dialog.tsx
import { DialogProps } from "dialog-manager-react";
type LoginDialogProps = { title: string } & DialogProps
export default function LoginDialog(props: LoginDialogProps) {
const { closeDialog, active, title } = props;
return <Component />
}
Using the hook inside a component
import { useDialogs } from './DialogManager'
export default function LoginButton() {
const { openDialog, closeDialog } = useDialogs()
const open = () => {
openDialog('loginDialog', { title: 'This is the title' })
}
const close = () => {
closeDialog()
}
return (
<>
<button onClick={open}>
Open
</button>
<button onClick={close}>
Close
</button>
</>
)
}
createDialogWrapper(dialogs: object, options: DialogWrapperOptions)
A key value of dialog names and ReactComponents.
const Dialogs = {
'loginDialog': Dialog, // Use functional components
'loginDialog2': lazy(() => import('./LoginDialog')) // Use lazy loaded components
};
key | default | Description | Type |
---|---|---|---|
showTimeout | 200 | Timeout between when the closeModal is called and the modal is removed from the dom | number |
suspenseFallback | null | Fallback loading state for lazy loaded components | ReactNode |
useDialog()
A hook to access the dialog context
openDialog(name: DialogName, props: ComponentProps)
Name of the dialog you defined
The props of that dialog component
FAQs
A headless dialog/modal manager for react.
The npm package dialog-manager-react receives a total of 11 weekly downloads. As such, dialog-manager-react popularity was classified as not popular.
We found that dialog-manager-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.