question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug when using import ReactBlockly from 'react-blockly' bug and 'index-dev.js' as entry point

See original GitHub issue

In the readme file wrote that:

Once you’ve done either of these, you should be able to import ReactBlockly from ‘react-blockly’; in your code and use ReactBlockly as a component.

But, basically, it’s not correct, I just try to use that like that but then it’s throwing an exception: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. The workaround for that is just to use the component as is: <ReactBlockly.BlocklyEditor .... />

The first interesting point is that in webpack.config the entry point is './src/dev-index.jsx' and not src/index.js - is it mistake or something ? The second point is that index.js export object and not a component and that’s why we can’t use that as component

Maybe a clarify will be good here! @nbudin I could change it myself but first I need to understand exactly what happening here! Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nbudincommented, Sep 17, 2020

Thanks for checking! This is now published as version 6.0.1.

To be honest, the main reason the build is the way it is is because that’s the way we built it originally at PatientsLikeMe and I haven’t wanted to mess with it. I don’t claim that it is the best possible choice overall, just that with the minimal amount of time I have to give to this package I haven’t wanted to risk breaking it by changing the build process.

One possible advantage of separate files is that if you only wanted to import one of the components, you could do it directly by path (e.g. import BlocklyToolbox from 'react-blockly/dist/BlocklyToolbox' or something like that), and then your bundle would be smaller than importing the whole thing. For this package, though, I can’t see a big advantage to that, since I assume almost everyone would want the whole thing.

In any case, I basically just haven’t wanted to risk breaking the build for everyone.

1reaction
nbudincommented, Sep 16, 2020

This is now shipped as version 6.0.0! Thanks for the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is webpack unable to find react when I'm using a custom ...
This problem is caused by the <script> tag in the HTML file ... what it happens to be set to in webpack.config.js module...
Read more >
Anyone have any luck getting Blockly to work with React?
I'm not having much luck getting Blockly to work in a Node.js/React application. ... posts about the error but I haven't come across...
Read more >
react-blockly - githubmemory
react-blockly repo issues. ... Bug when using import ReactBlockly from 'react-blockly' bug and 'index-dev.js' as entry point. MonkeyInWind.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found