uikit offcanvas display initially

I’m creating a react application using uikit framework. The problem is the offcanvas. I want it to be open when the page loads and close when a button clicks. I tried,

UIkit.util.ready(function() {
    UIkit.offcanvas('#offcanvas').show();
});

this. But it gives me this error.
Uncaught ReferenceError: UIkit is not defined

What am i doing wrong. Any help is really appreciated.