Preact: default import not working

Created on 17 Mar 2019  路  2Comments  路  Source: preactjs/preact

Next code from Getting started guide will crush

import preact from 'preact';

console.log(preact) // undefined

preact.render((
    <div id="foo">
        <span>Hello, world!</span>
    </div>
), document.body);

I see in console next warn and error
Cannot read property 'render' of undefined
"export 'default' (imported as 'preact') was not found in 'preact'

For fix i use next workaround:

import * as { preact } from 'preact';

If that expected behavior - please fix this example in manual.

My env:

preact: "10.0.0-alpha.2"
webpack: "4.29.6"
@babel/core: "7.3.4"
node: "v11.10.1"
yarn: "1.13.0"

Most helpful comment

yup, that's correct. We don't have a default export in core anymore. See the "Breaking Changes" section in the release notes for more information.

All 2 comments

That's right, I don't think there is a default export in the regular preact package at this point. However there is one in the Preact/Compat one.

yup, that's correct. We don't have a default export in core anymore. See the "Breaking Changes" section in the release notes for more information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriaanwm picture adriaanwm  路  3Comments

simonjoom picture simonjoom  路  3Comments

matuscongrady picture matuscongrady  路  3Comments

nopantsmonkey picture nopantsmonkey  路  3Comments

jasongerbes picture jasongerbes  路  3Comments