Skip to content

Commit

Permalink
Fix issue with onReady callback and tweak webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
talk2MeGooseman committed Mar 10, 2020
1 parent 9645fc9 commit 6e11952
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 474 deletions.
41 changes: 41 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
*.log
npm-debug.log*
yarn-error.log

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Dependency directories
node_modules

# npm package lock
package-lock.json
yarn.lock

# project files
src
test
examples
CHANGELOG.md
.travis.yml
.editorconfig
.eslintignore
.eslintrc
.babelrc
.gitignore


# lock files
package-lock.json
yarn.lock

# others
.DS_Store
.idea

.out
.github
.storybook
.config
stories
14 changes: 0 additions & 14 deletions .publishrc

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ import ReactTwitchEmbedVideo from "react-twitch-embed-video"
- Lowest version of React supported is now 16.8 (version React Hooks was introduced in)
- Removed onUserLogin, it appears Twitch stopped supporting this all together based off the docs
- Added targetId property for defining mutiple video players
- `onPlayerReady` renamed to `onReady`
- `onVideoPlay` renamed to `onPlay`

### Breaking Changes
In version one I was mistakenly using `targetClass` prop for populating the `id` attribute for the Twitch Player. So I created a new prop called `targetId` to use to define more then one Twitch Player on your page. `targetClass` now properly sets the class for the player for proper styling.
If you were one of the users the was creating more then on Twitch player on your page, just switch from using `targetClass` to `targetId` and things should still work properly.
If you're using `onPlayerReady` or `onVideoPlay`, make sure to rename them to the new prop names.

## Development

Expand Down
1 change: 1 addition & 0 deletions dist/index.js

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

1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
require('./dist/manifest');
module.exports = require('./dist/index').default;
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"window-or-global": "^1.0.1"
},
"peerDependencies": {
"react": "^16.8.0"
"react": ">= 16.3.0",
"react-dom": ">= 16.3.0"
},
"devDependencies": {
"@arkweid/lefthook": "^0.7.0",
Expand All @@ -51,6 +52,8 @@
"eslint": "^4.9.0",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-react-hooks": "^2.2.0",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-hot-loader": "^4.5.3",
"style-loader": "^0.19.0",
"webpack": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/usePlayerReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const usePlayerReady = (EmbedApi, options) =>
return;
}

const { getPlayer } = EmbedApi;
const { autoplay: isAutoPlay, muted: isMuted, onReady } = options || {};
const player = getPlayer();

const player = EmbedApi.getPlayer();

ensureVolume(player, isMuted);
ensureAutoPlay(player, isAutoPlay);

onReady && onReady(player);
onReady && onReady();
}, [EmbedApi, options]);

export { usePlayerReady };
4 changes: 2 additions & 2 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ storiesOf("React Twitch Embed Video", module)
.add("with video play callback", () => (
<TwitchEmbedVideo
channel="talk2megooseman"
onVideoPlay={action("onVideoPlay")}
onPlay={action("onVideoPlay")}
/>
))
.add("with player ready callback", () => (
<TwitchEmbedVideo
channel="talk2megooseman"
onPlayerReady={ignoreArgsAction("onPlayerReady")}
onReady={ignoreArgsAction("onPlayerReady")}
/>
));
5 changes: 1 addition & 4 deletions webpack.prod.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ module.exports = {
]
},

optimization: {
runtimeChunk: { name: 'manifest' }
},

plugins: [
// Clean dist folder
new CleanWebpackPlugin(['dist/*.*']),
]

};
Loading

0 comments on commit 6e11952

Please sign in to comment.