3.1.0 • Published 8 months ago

@hcfy/create-toaster v3.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Toaster.create() of Blueprintjs v5 uses ReactDOM.render(), which will generate warnings in React 18, so I created this module to replace Toaster.create().

Before:

const toaster = Toaster.create(props, container)

After:

import { createToaster } from '@hcfy/create-toaster'

const toasterPromise = createToaster(props, container)

toasterPromise.then(toaster =>{
  toaster.show({ message: 'Hello toaster!' })
})

You can also use the following hook to use it synchronously in function components:

import { createToaster, useToasterState }  from '@hcfy/create-toaster'

const toasterPromise = createToaster(props, container)

function App() {
  const toaster = useToasterState(toasterPromise)

  useEffect(() => {
    toaster?.show({ message: 'Hello toaster!' })
  }, [toaster])
}

or:

import { createToaster, useToasterRef }  from '@hcfy/create-toaster'

const toasterPromise = createToaster(props, container)

function App() {
  const toasterRef = useToasterRef(toasterPromise)

  useEffect(() => {
    toasterRef.current?.show({ message: 'Hello toaster!' })
  }, [toasterRef.current])
}
3.1.0

8 months ago

3.0.1

9 months ago

3.0.0

9 months ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago