Skip to content

Commit

Permalink
Remove react-is dependency (#272)
Browse files Browse the repository at this point in the history
* Remove react-is dependency

* Update CHANGELOG

* 0.9.15
  • Loading branch information
iamhosseindhv authored May 17, 2020
1 parent 297f229 commit d73be98
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Thanks to all contributers who improved notistack by opening an issue/PR.
### `notistack@0.9.15`
###### May 17, 2020
* **@nebojsanb**: Fix bug with displaying snackbars [#270](/~https://github.com/iamhosseindhv/notistack/issues/270)

* **@nebojsanb**: Improve bundle size by removing `react-is` dependency [#272](/~https://github.com/iamhosseindhv/notistack/pull/272)

<br />

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notistack",
"version": "0.9.14",
"version": "0.9.15",
"description": "Highly customizable notification snackbars (toasts) that can be stacked on top of each other",
"main": "dist/index.js",
"module": "dist/notistack.esm.js",
Expand Down Expand Up @@ -54,8 +54,7 @@
},
"dependencies": {
"clsx": "^1.1.0",
"hoist-non-react-statics": "^3.3.0",
"react-is": "^16.8.6"
"hoist-non-react-statics": "^3.3.0"
},
"bugs": {
"url": "/~https://github.com/iamhosseindhv/notistack/issues"
Expand Down
13 changes: 10 additions & 3 deletions src/utils/getDisplayName.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ForwardRef } from 'react-is';

// /~https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
const getFunctionName = (fn) => {
Expand All @@ -24,6 +22,15 @@ const getWrappedName = (outerType, innerType, wrapperName) => {
);
};

/**
* From react-is
* @link /~https://github.com/facebook/react/blob/master/packages/shared/ReactSymbols.js
*/
const ForwardRef = () => {
const symbolFor = typeof Symbol === 'function' && Symbol.for;
return symbolFor ? symbolFor('react.forward_ref') : 0xead0
}

/**
* /~https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
*
Expand All @@ -45,7 +52,7 @@ export default (Component) => {

if (typeof Component === 'object') {
switch (Component.$$typeof) {
case ForwardRef:
case ForwardRef():
return getWrappedName(Component, Component.render, 'ForwardRef');
default:
return undefined;
Expand Down

0 comments on commit d73be98

Please sign in to comment.