Skip to content

Commit

Permalink
fixes the dereference of twttr on window
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj committed Mar 26, 2019
1 parent fb151e7 commit cedfcd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-tweet-embed",
"version": "1.2.1",
"version": "1.2.2",
"description": "react component that takes tweet id in props and renders tweet embed, nothing more",
"main": "dist/tweet-embed.js",
"module": "dist/tweet-embed.es.js",
Expand Down
4 changes: 2 additions & 2 deletions src/tweet-embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ class TweetEmbed extends React.Component<ITweetEmbedProps> {
isLoading: true
}
loadTweetForProps(props: ITweetEmbedProps) {
const twttr = window['twttr']

const renderTweet = () => {
const twttr = window['twttr']
twttr.ready().then(({ widgets }) => {
// Clear previously rendered tweet before rendering the updated tweet id
if (this._div) {
Expand All @@ -72,6 +71,7 @@ class TweetEmbed extends React.Component<ITweetEmbedProps> {
})
}

const twttr = window['twttr']
if (!(twttr && twttr.ready)) {
const isLocal = window.location.protocol.indexOf('file') >= 0
const protocol = isLocal ? this.props.protocol : ''
Expand Down

0 comments on commit cedfcd0

Please sign in to comment.