3

I have added Intro.js as below in one of my components:

import introJs from 'intro.js';

Then called it in componentDidMount

    componentDidMount() {
    introJs().start();
}

Element where I am using it at:

 <div className={cx('dropDownSortingBlock')}>
                {!isTrending && <div className={cx('dropDown')} data-intro={'Hello step one!'}>

However when i import css into a parent component

enter image description here

It doesn't render the component.

enter image description here

Update:

I tried using intro.js react wrapper and i have imported css directly into my file now.

However it just doesn't work

 constructor() {
        super();

        this.state = {
            showMessage: false,
            type: '',
            message: '',
            stepsEnabled: true,
            initialStep: 0,
            steps: [
                {
                    element: '.snapshotWrapper',
                    intro: 'Hello step',
                },
                {
                    element: '.snapshotWrapperNew',
                    intro: 'Hello Sort wrapper',
                },
            ],
        };
    }

In render

  <Steps
            enabled={this.state.stepsEnabled}
            steps={this.state.steps}
            initialStep={this.state.initialStep}
            onExit={this.onExit}
                    />

Below is what shows up:

enter image description here

5
  • By doesn't render you mean the component is not present in DOM at all, or you simply can't see it? Commented Aug 6, 2019 at 12:11
  • The component is present @AdamKosmala the css isn't getting applied Commented Aug 6, 2019 at 12:36
  • I would verify if ListLandingPage.css is loaded at all anywhere and if the imported files are available in your css bundle. I'm not familiar with introJs, but maybe try also replacing your import with import * as introJs from 'intro.js' Commented Aug 6, 2019 at 12:40
  • @vini Please raise this on their github Commented Aug 6, 2019 at 15:47
  • @vini I'm presuming you're using webpack? If so what's your config? Commented Aug 14, 2019 at 14:15

3 Answers 3

7
+25

Because you're importing the css file from the package in node_modules , Add the ~ to your import in ListLandingPage.css :

@import "~intro.js/introjs.css";

see Import CSS from "node_modules" in Webpack

Or, import it in your component ( without the ~ ) :

import introJs from 'intro.js';
import 'intro.js/introjs.css'; 

Howerver, I would suggest you use the React wrapper around Intro.js for a React app.

they even have a code sandbox to get started

Sign up to request clarification or add additional context in comments.

3 Comments

I tried the React Wrapper It didnt work out same issue will try this thanks.
am getting module loader failed
when using the ~ or when importing it in the component (without the ~)?
1

Please use react wrapper for intro.js.

  1. npm install intro.js-react
  2. also install intro js -- > npm install intro.js --save
  3. then you can import css files from node modules like this below import "intro.js/introjs.css" themes are also available on the themes folder.(for eg: import "intro.js/themes/introjs- nassim.css";)
  4. Wrapper works similarly. Define steps / hints inside component. for that :- import { Steps, Hints } from "intro.js-react";

Comments

0

Did you try https://www.npmjs.com/package/intro.js-react . It is a small React wrapper around Intro.js. The wrapper provides support for both steps and hints

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.