Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast id is not available to custom content #35

Closed
benhodgson87 opened this issue Oct 22, 2019 · 3 comments
Closed

Toast id is not available to custom content #35

benhodgson87 opened this issue Oct 22, 2019 · 3 comments

Comments

@benhodgson87
Copy link

benhodgson87 commented Oct 22, 2019

As far as I can tell, currently if a custom content component is provided, no props are made available to it. This means that as no close icon is shown it requires dismiss.click to be true to allow the user to dismiss the toast - which clashes if the custom toast contains something like a react-router Link or any other click handler.

Ideally content should pass down the id of the toast as a prop to allow the custom component to call the removeNotification(id) method on itself.

eg:

store.addNotification({
  content: ({ id }) => (
    <div>
      Item added to <Link to="/basket">your basket</Link>
      <br />
      <button onClick={() => store.removeNotification(id)}>× Dismiss</button>
    </div>
  )
})
@benhodgson87 benhodgson87 changed the title Toast id is not available to custom components Toast id is not available to custom content Oct 22, 2019
@teodosii
Copy link
Owner

Hmm, you're correct. Will do a fix these days

@teodosii
Copy link
Owner

teodosii commented Nov 6, 2019

Fixed, will be released in 2.2.0

@teodosii teodosii closed this as completed Nov 6, 2019
@jabidof
Copy link

jabidof commented Feb 9, 2020

Hi,
Nice lib.

I need the notification ID for different usage.
I tried above example without success :-(

I keep getting below errors.

TypeError: Cannot read property 'isReactComponent' of undefined
isClassComponent
src/utils/validators.js:12
   9 | const isArray = object => !isNull(object) && object.constructor === Array;
  10 | 
  11 | function isClassComponent(component) {
> 12 |   return typeof component === 'function' && !!component.prototype.isReactComponent;

Seems the integration of React component in "content" prop is the issue.

Could you provide a working example with custom content?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants