Skip to content

Commit

Permalink
Initialize font manager after component mount
Browse files Browse the repository at this point in the history
Fixes #29
  • Loading branch information
samuelmeuli committed May 13, 2020
1 parent 40eb7e3 commit 0c098cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/FontPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export default class FontPicker extends PureComponent<Props, State> {
sort,
};

// Initialize FontManager object and generate font list
// Initialize FontManager object
this.fontManager = new FontManager(apiKey, activeFontFamily, options, onChange);
}

componentDidMount = (): void => {
// Generate font list
this.fontManager
.init()
.then((): void => {
Expand All @@ -109,7 +113,7 @@ export default class FontPicker extends PureComponent<Props, State> {
console.error("Error trying to fetch the list of available fonts");
console.error(err);
});
}
};

/**
* After every component update, check whether the activeFontFamily prop has changed. If so,
Expand Down

0 comments on commit 0c098cb

Please sign in to comment.