HiDeoo / intro.js-react

Intro.js react wrapper
MIT License
395 stars 58 forks source link

Options are not working in intro-react.js #98

Closed saisubrahmanyamlanka closed 1 year ago

saisubrahmanyamlanka commented 1 year ago

Describe the bug

Hi,

i want to change the default name of the Next label and customize the existing options. however it didn't work for me My sample code was

<Hints enabled={hintsEnabled} hints={hints} options={{nextLabel: 'd'}} />

do we need to import any other JS files/libraries? can someone please help me on it?

To Reproduce

import React, { Component } from "react"; import { render } from "react-dom"; import { Steps, Hints } from "intro.js-react"; import "intro.js/introjs.css"; import "./index.css";

export default class App extends Component { options: { nextLabel: "kk" }; constructor(props) { super(props);

this.state = {
  stepsEnabled: true,
  initialStep: 0,

  steps: [
    {},
    {
      element: ".hello",
      intro: "Hello step"
    },
    {
      element: ".world",
      intro: "World step"
    }
  ],
  hintsEnabled: true,
  hints: [
    {
      element: ".hello",
      hint: "Hello hint",
      hintPosition: "middle-right"
    }
  ]      
};

}

render() { const { stepsEnabled, steps, initialStep, hintsEnabled, hints, options } = this.state; console.log(options); return (

Hello,


World!


It's alive!

);

}

onExit = () => { this.setState(() => ({ stepsEnabled: false })); };

toggleSteps = () => { this.setState(prevState => ({ stepsEnabled: !prevState.stepsEnabled })); };

addStep = () => { const newStep = { element: ".alive", intro: "Alive step" };

this.setState(prevState => ({ steps: [...prevState.steps, newStep] }));

};

toggleHints = () => { this.setState(prevState => ({ hintsEnabled: !prevState.hintsEnabled })); }; addHint = () => { const newHint = { element: ".alive", hint: "Alive hint", hintPosition: "middle-right" };

this.setState(prevState => ({ hints: [...prevState.hints, newHint] }));

}; }

render(, document.getElementById("root"));

Expected behavior

i want to change the existing name of options those are nextlabel, prevlabel, skiplabel, etc...

How often does this bug happen?

Every time

System Info

No response

Additional Context

No response

HiDeoo commented 1 year ago

Hi,

The hint options are slightly different from the step ones and are documented here.

In order to customize the hint button label, you have to use the hintButtonLabel option, e.g. <Hints enabled hints={hints} options={{ hintButtonLabel: "Custom hint button label" }} />.

You can find a working example in this codesandbox.