Materializecss tabs are not working with React (npm import) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How do JavaScript closures work?How does JavaScript .prototype work?How does the “this” keyword work?Open a URL in a new tab (and not a new window) using JavaScriptHow does data binding work in AngularJS?What is the difference between Bower and npm?Loop inside React JSXWhat do these three dots in React do?Programmatically navigate using react router$('select').material_select() is not a function - initialising Materializecss select field in React

Wu formula for manifolds with boundary

How do I find out the mythology and history of my Fortress?

Irreducible of finite Krull dimension implies quasi-compact?

Do wooden building fires get hotter than 600°C?

Is there any way for the UK Prime Minister to make a motion directly dependent on Government confidence?

How can I use the Python library networkx from Mathematica?

Quick way to create a symlink?

Did MS DOS itself ever use blinking text?

How to react to hostile behavior from a senior developer?

Why are both D and D# fitting into my E minor key?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Circuit to "zoom in" on mV fluctuations of a DC signal?

How does the math work when buying airline miles?

Can a new player join a group only when a new campaign starts?

What's the meaning of "fortified infraction restraint"?

Around usage results

Should I use a zero-interest credit card for a large one-time purchase?

How to answer "Have you ever been terminated?"

How to Make a Beautiful Stacked 3D Plot

What is homebrew?

How to compare two different files line by line in unix?

Can an alien society believe that their star system is the universe?

Find the length x such that the two distances in the triangle are the same

How come Sam didn't become Lord of Horn Hill?



Materializecss tabs are not working with React (npm import)



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How do JavaScript closures work?How does JavaScript .prototype work?How does the “this” keyword work?Open a URL in a new tab (and not a new window) using JavaScriptHow does data binding work in AngularJS?What is the difference between Bower and npm?Loop inside React JSXWhat do these three dots in React do?Programmatically navigate using react router$('select').material_select() is not a function - initialising Materializecss select field in React



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I've been looking through other people's solutions to my problem and the Materializecss documentation, but I can't get the MaterializeCss tabs and other components under the javascript section to work in my React project.



import M from 'materialize-css';

componentDidMount()
let el = document.querySelector('.tabs');
let instance = M.Tabs.init(el, );


render()
return (
<div className="App">
<div className="row">
<div className="col s12">
<ul className="tabs">
<li className="tab col s3">
<a href="#test1">Test 1</a>
</li>
<li className="tab col s3">
<a className="active" href="#test2">
Test 2
</a>
</li>
<li className="tab col s3 disabled">
<a href="#test3">Disabled Tab</a>
</li>
<li className="tab col s3">
<a href="#test4">Test 4</a>
</li>
</ul>
</div>
<div id="test1" className="col s12">
Test 1
</div>
<div id="test2" className="col s12">
Test 2
</div>
<div id="test3" className="col s12">
Test 3
</div>
<div id="test4" className="col s12">
Test 4
</div>
</div>
</div>
);




I've tried the Jquery implementation as well but that doesn't work either. Just putting script tags and the tabs code in the body of my index.html file works, but is very limiting. I'm required to use MaterializeCss so react-materialize isn't an option.



Would love to get some advice on this.










share|improve this question






















  • are there no errors int the browser console?

    – azium
    Mar 8 at 19:31











  • no errors in the console

    – BvdL
    Mar 8 at 19:37

















0















I've been looking through other people's solutions to my problem and the Materializecss documentation, but I can't get the MaterializeCss tabs and other components under the javascript section to work in my React project.



import M from 'materialize-css';

componentDidMount()
let el = document.querySelector('.tabs');
let instance = M.Tabs.init(el, );


render()
return (
<div className="App">
<div className="row">
<div className="col s12">
<ul className="tabs">
<li className="tab col s3">
<a href="#test1">Test 1</a>
</li>
<li className="tab col s3">
<a className="active" href="#test2">
Test 2
</a>
</li>
<li className="tab col s3 disabled">
<a href="#test3">Disabled Tab</a>
</li>
<li className="tab col s3">
<a href="#test4">Test 4</a>
</li>
</ul>
</div>
<div id="test1" className="col s12">
Test 1
</div>
<div id="test2" className="col s12">
Test 2
</div>
<div id="test3" className="col s12">
Test 3
</div>
<div id="test4" className="col s12">
Test 4
</div>
</div>
</div>
);




I've tried the Jquery implementation as well but that doesn't work either. Just putting script tags and the tabs code in the body of my index.html file works, but is very limiting. I'm required to use MaterializeCss so react-materialize isn't an option.



Would love to get some advice on this.










share|improve this question






















  • are there no errors int the browser console?

    – azium
    Mar 8 at 19:31











  • no errors in the console

    – BvdL
    Mar 8 at 19:37













0












0








0








I've been looking through other people's solutions to my problem and the Materializecss documentation, but I can't get the MaterializeCss tabs and other components under the javascript section to work in my React project.



import M from 'materialize-css';

componentDidMount()
let el = document.querySelector('.tabs');
let instance = M.Tabs.init(el, );


render()
return (
<div className="App">
<div className="row">
<div className="col s12">
<ul className="tabs">
<li className="tab col s3">
<a href="#test1">Test 1</a>
</li>
<li className="tab col s3">
<a className="active" href="#test2">
Test 2
</a>
</li>
<li className="tab col s3 disabled">
<a href="#test3">Disabled Tab</a>
</li>
<li className="tab col s3">
<a href="#test4">Test 4</a>
</li>
</ul>
</div>
<div id="test1" className="col s12">
Test 1
</div>
<div id="test2" className="col s12">
Test 2
</div>
<div id="test3" className="col s12">
Test 3
</div>
<div id="test4" className="col s12">
Test 4
</div>
</div>
</div>
);




I've tried the Jquery implementation as well but that doesn't work either. Just putting script tags and the tabs code in the body of my index.html file works, but is very limiting. I'm required to use MaterializeCss so react-materialize isn't an option.



Would love to get some advice on this.










share|improve this question














I've been looking through other people's solutions to my problem and the Materializecss documentation, but I can't get the MaterializeCss tabs and other components under the javascript section to work in my React project.



import M from 'materialize-css';

componentDidMount()
let el = document.querySelector('.tabs');
let instance = M.Tabs.init(el, );


render()
return (
<div className="App">
<div className="row">
<div className="col s12">
<ul className="tabs">
<li className="tab col s3">
<a href="#test1">Test 1</a>
</li>
<li className="tab col s3">
<a className="active" href="#test2">
Test 2
</a>
</li>
<li className="tab col s3 disabled">
<a href="#test3">Disabled Tab</a>
</li>
<li className="tab col s3">
<a href="#test4">Test 4</a>
</li>
</ul>
</div>
<div id="test1" className="col s12">
Test 1
</div>
<div id="test2" className="col s12">
Test 2
</div>
<div id="test3" className="col s12">
Test 3
</div>
<div id="test4" className="col s12">
Test 4
</div>
</div>
</div>
);




I've tried the Jquery implementation as well but that doesn't work either. Just putting script tags and the tabs code in the body of my index.html file works, but is very limiting. I'm required to use MaterializeCss so react-materialize isn't an option.



Would love to get some advice on this.







javascript reactjs materialize






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 18:51









BvdLBvdL

4227




4227












  • are there no errors int the browser console?

    – azium
    Mar 8 at 19:31











  • no errors in the console

    – BvdL
    Mar 8 at 19:37

















  • are there no errors int the browser console?

    – azium
    Mar 8 at 19:31











  • no errors in the console

    – BvdL
    Mar 8 at 19:37
















are there no errors int the browser console?

– azium
Mar 8 at 19:31





are there no errors int the browser console?

– azium
Mar 8 at 19:31













no errors in the console

– BvdL
Mar 8 at 19:37





no errors in the console

– BvdL
Mar 8 at 19:37












1 Answer
1






active

oldest

votes


















1














It can be implemented in materializeCSS also.
For this you need to do npm install materialize-css@next. After this, you need to import the materialize-css in your component JS file.



To use the Javascript materialize-css components, a reference of these components has to be made in componentDidMount() has to be made and then it can be used in ref.



Working Demo - Tabs MaterializeCSS



import React, Component from "react";
import M from "materialize-css";
import "materialize-css/dist/css/materialize.min.css";

class Tabs extends Component
componentDidMount()
M.Tabs.init(this.Tabs);

render()
return (
<>
<ul
ref=Tabs =>
this.Tabs = Tabs;

id="tabs-swipe-demo"
class="tabs"
>
<li class="tab col s3">
<a href="#test-swipe-1">Test 1</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-3">Test 3</a>
</li>
</ul>

<div id="test-swipe-1" class="col s12 blue">
Test 1
</div>
<div id="test-swipe-2" class="col s12 red">
Test 2
</div>
<div id="test-swipe-3" class="col s12 green">
Test 3
</div>
</>
);



export default Tabs;





share|improve this answer























  • The ref is what did it. Thank you, really helped me out

    – BvdL
    Mar 9 at 12:56











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069297%2fmaterializecss-tabs-are-not-working-with-react-npm-import%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














It can be implemented in materializeCSS also.
For this you need to do npm install materialize-css@next. After this, you need to import the materialize-css in your component JS file.



To use the Javascript materialize-css components, a reference of these components has to be made in componentDidMount() has to be made and then it can be used in ref.



Working Demo - Tabs MaterializeCSS



import React, Component from "react";
import M from "materialize-css";
import "materialize-css/dist/css/materialize.min.css";

class Tabs extends Component
componentDidMount()
M.Tabs.init(this.Tabs);

render()
return (
<>
<ul
ref=Tabs =>
this.Tabs = Tabs;

id="tabs-swipe-demo"
class="tabs"
>
<li class="tab col s3">
<a href="#test-swipe-1">Test 1</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-3">Test 3</a>
</li>
</ul>

<div id="test-swipe-1" class="col s12 blue">
Test 1
</div>
<div id="test-swipe-2" class="col s12 red">
Test 2
</div>
<div id="test-swipe-3" class="col s12 green">
Test 3
</div>
</>
);



export default Tabs;





share|improve this answer























  • The ref is what did it. Thank you, really helped me out

    – BvdL
    Mar 9 at 12:56















1














It can be implemented in materializeCSS also.
For this you need to do npm install materialize-css@next. After this, you need to import the materialize-css in your component JS file.



To use the Javascript materialize-css components, a reference of these components has to be made in componentDidMount() has to be made and then it can be used in ref.



Working Demo - Tabs MaterializeCSS



import React, Component from "react";
import M from "materialize-css";
import "materialize-css/dist/css/materialize.min.css";

class Tabs extends Component
componentDidMount()
M.Tabs.init(this.Tabs);

render()
return (
<>
<ul
ref=Tabs =>
this.Tabs = Tabs;

id="tabs-swipe-demo"
class="tabs"
>
<li class="tab col s3">
<a href="#test-swipe-1">Test 1</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-3">Test 3</a>
</li>
</ul>

<div id="test-swipe-1" class="col s12 blue">
Test 1
</div>
<div id="test-swipe-2" class="col s12 red">
Test 2
</div>
<div id="test-swipe-3" class="col s12 green">
Test 3
</div>
</>
);



export default Tabs;





share|improve this answer























  • The ref is what did it. Thank you, really helped me out

    – BvdL
    Mar 9 at 12:56













1












1








1







It can be implemented in materializeCSS also.
For this you need to do npm install materialize-css@next. After this, you need to import the materialize-css in your component JS file.



To use the Javascript materialize-css components, a reference of these components has to be made in componentDidMount() has to be made and then it can be used in ref.



Working Demo - Tabs MaterializeCSS



import React, Component from "react";
import M from "materialize-css";
import "materialize-css/dist/css/materialize.min.css";

class Tabs extends Component
componentDidMount()
M.Tabs.init(this.Tabs);

render()
return (
<>
<ul
ref=Tabs =>
this.Tabs = Tabs;

id="tabs-swipe-demo"
class="tabs"
>
<li class="tab col s3">
<a href="#test-swipe-1">Test 1</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-3">Test 3</a>
</li>
</ul>

<div id="test-swipe-1" class="col s12 blue">
Test 1
</div>
<div id="test-swipe-2" class="col s12 red">
Test 2
</div>
<div id="test-swipe-3" class="col s12 green">
Test 3
</div>
</>
);



export default Tabs;





share|improve this answer













It can be implemented in materializeCSS also.
For this you need to do npm install materialize-css@next. After this, you need to import the materialize-css in your component JS file.



To use the Javascript materialize-css components, a reference of these components has to be made in componentDidMount() has to be made and then it can be used in ref.



Working Demo - Tabs MaterializeCSS



import React, Component from "react";
import M from "materialize-css";
import "materialize-css/dist/css/materialize.min.css";

class Tabs extends Component
componentDidMount()
M.Tabs.init(this.Tabs);

render()
return (
<>
<ul
ref=Tabs =>
this.Tabs = Tabs;

id="tabs-swipe-demo"
class="tabs"
>
<li class="tab col s3">
<a href="#test-swipe-1">Test 1</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3">
<a href="#test-swipe-3">Test 3</a>
</li>
</ul>

<div id="test-swipe-1" class="col s12 blue">
Test 1
</div>
<div id="test-swipe-2" class="col s12 red">
Test 2
</div>
<div id="test-swipe-3" class="col s12 green">
Test 3
</div>
</>
);



export default Tabs;






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 11:49









Germa VinsmokeGerma Vinsmoke

1,0852620




1,0852620












  • The ref is what did it. Thank you, really helped me out

    – BvdL
    Mar 9 at 12:56

















  • The ref is what did it. Thank you, really helped me out

    – BvdL
    Mar 9 at 12:56
















The ref is what did it. Thank you, really helped me out

– BvdL
Mar 9 at 12:56





The ref is what did it. Thank you, really helped me out

– BvdL
Mar 9 at 12:56



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069297%2fmaterializecss-tabs-are-not-working-with-react-npm-import%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович