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.

Can not use material-ui components inside React4s components

See original GitHub issue

Steps:

  • add cdn for material-ui in index.html of react4s-samples
 <script src="https://unpkg.com/@material-ui/core/umd/material-ui.production.min.js" crossorigin="anonymous"></script>
  • Create a react4s wrapper for Button component
import com.github.ahnfelt.react4s.JsComponent
import scala.scalajs.js
object Button extends JsComponent(js.Dynamic.global.Button)
  • Use the Button wrapper in Main.scala as following
ReactBridge.renderToDomById(Button(), "main")
  • fastOptJS and reload the index.html

We get the error:

Uncaught Error: Minified React error #130; visit http://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings. 
    at ze (react-dom.production.min.js:82)
    at l (react-dom.production.min.js:12)
    at ec (react-dom.production.min.js:46)
    at react-dom.production.min.js:61
    at k (react-dom.production.min.js:129)
    at h (react-dom.production.min.js:129)
    at beginWork (react-dom.production.min.js:137)
    at e (react-dom.production.min.js:168)
    at f (react-dom.production.min.js:169)
    at A (react-dom.production.min.js:175)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
avitalncommented, May 23, 2018

I think I had the same issue. try this:

object Main {
  def main(arguments: Array[String]): Unit = {
    NpmReactBridge.renderToDomById(Component(MainComponent), "main")
  }
}

NpmReactBridge borrowed from @Taig’s library

0reactions
Poorva17commented, May 23, 2018

@avitaln Yes. plugins.sbt is exact same. I tried putting bundle JS after main div as well. Still getting same error as in #11.

@Taig I will refer to react4s-mui. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Material UI components not working in React JS project
Try import Button from '@mui/material/Button'; ... Component { return ( <div className="App"> <h1>COVID-19 ... Please use this command.
Read more >
Material UI v4 is out - MUI
Material UI v4 has finally arrived. We are so excited about this release, as it defines better foundations for the UI components.
Read more >
How to Implement Material-UI in React - Section.io
We must install the Material-UI to access its different functionalities or components. Open your terminal, and ensure that you are inside your ...
Read more >
Uncontrolled Components - React
In React, an <input type="file" /> is always an uncontrolled component because its value can only be set by a user, and not...
Read more >
5 React Material UI Features You Might Have Missed
Just to give you an overview, Material UI doesn't limit you to only JSS based styling. If you love using Styled-Components or CSS...
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