Skip to content

Issue in declaring the Class in es6 project. #102

@MVSTEJA

Description

@MVSTEJA

I am using the font face observer in my react es6 project this way --

import FontFaceObserver from 'fontfaceobserver';
const openSansObserver = new FontFaceObserver('Open Sans');

Or even this , as is mentioned in the docs -
var FontFaceObserver = require('fontfaceobserver');
const openSansObserver = new FontFaceObserver('Open Sans');

and its throwing error such as this.
_fontfaceobserver2.default is not a constructor. / FontFaceObserver is not a constructor

Not using modules?
You can also download a copy and manually include it in your project. You can then use the global Font­Face­Observer constructor to load your fonts. This somehow works for me as shown below, but above two should either be broken now or there is something in the way you guys export your module. If i am wrong please ignore this. Else kindly change the the export.

Working Version -

require('fontfaceobserver');
const openSansObserver = new FontFaceObserver('Open Sans');//eslint-disable-line no-undef

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions