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

[alpha] Add .bind(this) to method stored in provider state #397

Merged
merged 1 commit into from
Aug 21, 2021

Conversation

anthonyraymond
Copy link
Contributor

Fix #393

@anthonyraymond anthonyraymond changed the title Add .bind(this) to method stored in provider state [alpha] Add .bind(this) to method stored in provider state Jun 14, 2021
@tifosiblack
Copy link

Could we merge this as it's a blocking issue

@bpred754

This comment has been minimized.

@emilshr
Copy link

emilshr commented Jul 26, 2021

Merging this PR will be great!
Even I am stuck with this blocking issue

My current config:
"@material-ui/core": "4.11.0"

I've been seeing people reporting this issue on alpha versions of MUI.
I'm reporting the same issue on 4.11.0 as well.

@tifosiblack
Copy link

Meanwhile I used a workaround :

class FixedSnackbarProvider<
  V extends keyof T,
  T extends Record<V, React.ComponentType<any>>,
> extends SnackbarProvider<V, T> {
  constructor(props: SnackbarProviderProps) {
    super(props)
    const { enqueueSnackbar, closeSnackbar } = (this.state as any).contextValue

    this.state = {
      ...this.state,
      contextValue: {
        enqueueSnackbar: enqueueSnackbar.bind(this),
        closeSnackbar: closeSnackbar.bind(this),
      },
    }
  }
}

@emilshr
Copy link

emilshr commented Aug 11, 2021

I have used this temporary fix and it works great!
Thanks @tifosiblack

@iamhosseindhv iamhosseindhv merged commit 4d8be86 into iamhosseindhv:alpha Aug 21, 2021
@iamhosseindhv
Copy link
Owner

Thanks for your contribution ❤️ . You can download the fix by npm i notistack@alpha.

@anthonyraymond anthonyraymond deleted the patch-1 branch August 24, 2021 08:17
iamhosseindhv added a commit that referenced this pull request Mar 6, 2023
* Add goober

* Use goober for SnackbarContainer

* Use goober from SnackbarContent

* Convert Snackbar component to Typescript

* Add material design content

* Process props and pass to custom snackbar

* No spreading

* Reuse enqueueSnackbar type

* Add WIP migration guide

* Add tslib to devDep

* Remove duplicate eslintrc

* Render SnackbarContainer children

* Default content should forwardRef

* Fix bug with collapse classes

* Don't drop support for `content` prop just yet

* Remove duplicate className

* Use useSnackbar in the basic example

* Update Migration md

* Add links to the right section

* No memo for SnackbarContent

* Bump version to v2

* 2.0.1-alpha.0

* Update typedoc.json

* No imports from outside in index.d.ts

* 2.0.1-alpha.1

* Update typedoc.json

* Ensure CustomSnackbarProps type is accurate

* Use Generics for Variant

* 2.0.1-alpha.2

* Minor

* Add more strict types

* 2.0.1-alpha.3

* Get message from options only

* Move minWidth to snackbar for easier customisation

* Add MIGRATION to npmignore

* Make intellisense happy

* Apply Collapse customisation in SnackbarContainer

* Fix various issues with Container component

* Add default background color

* Add ComponentClasses

* Update typedoc.json

* 2.0.1-alpha.4

* [alpha] Add .bind(this) to method stored in provider state (#397)

* Fix easy linting issues

* Import types from types.ts file

* Fix bind.this

* Fix collapse selectors

* Update package-lock

* 2.0.1-alpha.5

* Fix ts-ignore

* v3.0.0-alpha.1

* Use clickaway component

* Add useForkRef

* Rename class keys

* Use internal svg icon

* Use internal transition components

* Fixes #396 #389 - Do not use css selectors for Collapse component

* Add useCallbackNormaliser

* Update SnackbarProvider types

* Use internal Collapse component

* Add transition utils

* Rename close reason

* Update types

* Remove MUI dependency

* Move transitions into their directory

* Improve transition import paths

* Add react-transition-group types

* Update import paths for ui components

* Add index export

* Move useForkRef

* Move SnackbarContainer

* Update path to SnackbarProvider

* Update possible transition components

* Default to MaterialDesignContent in SnackbarItem

* Move util functions to the relevant file

* Move warning messages to the relevant file

* Remove CloseReason constant

* Improve merge helper function

* Move merger into its own file

* Rename file and update import paths

* Update docs

* Add np as publisher

* Update published main path

* Copy files to dist folder

* Add np

* No github drafter

* Add npm scripts

* Add custom component example

* Update indentation from 4 to 2 spaces

* Add readme

* Add readme with codesandbox button

* Remove react-transition-group dep

* Add internal transition component

* Fix bug with warning logger

* SnackbarItem don't add snackbarid as arg to transition callbacks

* Minor

* Simplify transition logic by removing useCallbackNormaliser

* Update migration guide

* Add `id` to transition props

* Update typedoc

* 3.0.0-alpha.2

* Minor change

* Update link codesandbox example

* Export transitions

* Remove fontFamily stylings

* Update variant types

* Regenerate doc defs

* Move types in one file

* Regenerate docs

* Ignore prettier config

* enforce node engine

* Support react 18

* Remove yolo

* Update np version

* Update docs

* Copy package.json before packing

* Rename lifecycle script

* Add postversion script

* Fix typo

* v3.0.0-alpha.3

* Minor

* Update links to notistack website

* Minor

* Add second custom example

* Add report complete example

* Update report complete example

* Update alpha engine versions (#497)

Co-authored-by: Antti Ahti <[email protected]>

* Update jsdocs

* v3.0.0-alpha.4

* Fixes #495 - FIx all snackbars closing at the same time (#498)

* v3.0.0-alpha.5

* Use a more simple Collapse

* Remove getAutoHeightDuration as a file

* Update eslint config

* Run eslint fix

* Remove ClickAway listener

* Minor

* Convert transition component to TS

* Move TransitionStatus type

* Remove transitions

* Export Transition component

* Update types to export Transition component

* Address ts errors

* Move cp commands to package.json

* Update scripts

* Add test script

* Update np config

* v3.0.0-alpha.6

* Update banner image to be served from docs website

* Add support for displaying Snackbars outside of the component (#499)

* Add support for displaying snackbars outside of the component

* Update README instructions

* Update MIGRATION.md

* Remove withSnackbar HOC (#500)

* Convert JS files to TS

* v3.0.0-alpha.7

* Closes #501 - Remove clickaway from docs

* Fixes #513 - Ensure MUI transitions continue to work (#518)

* Update transition types

* Ensure MUI transitions continue to work

* Update typedocs

* v3.0.0-alpha.8

* Add render function SnackbarProvider

* v3.0.0-alpha.9

* Update typedocs

* v3.0.0-alpha.10

* Closes #521 - Update SnackbarContent to accept ref type

* v3.0.0-alpha.11

* Allow overriding styles of Material Snackbar (#545)

* Pass className down to snackbar content

* Add MuiContent-variant classname

* Export MaterialDesignContent component

* Update typedocs

* Minor

* v3.0.0-alpha.12

* v3.0.0-alpha.13

* Update CHANGELOG.md

* Update README.md

---------

Co-authored-by: Anthony Raymond <[email protected]>
Co-authored-by: Antti Ahti <[email protected]>
Co-authored-by: Antti Ahti <[email protected]>
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

Successfully merging this pull request may close these issues.

7 participants