Giter VIP home page Giter VIP logo

Comments (7)

TaylorBriggs avatar TaylorBriggs commented on June 25, 2024

Hi @kirkryan, thanks for the question. It sounds like you want to use multiple instances of TypeWriter in your component and set each one's typing prop to 1 after the user is prompted for input. You can use a wrapper component's state to coordinate the multiple instances. You can use the onTypingEnd callback to track how far along the user is in the steps and set the state to make the next instance of TypeWriter start typing. Hope that helps!

from react-native-typewriter.

kirkryan avatar kirkryan commented on June 25, 2024

Actually that’s a great idea! I’d forgotten about using the typing prop and simply used conditional rendering to wrap each Typewriter component then show or hide it based on the progress of the user. Is the onTypingEnd only fired once the complete payload is written out on screen? I believe when I tried using it, it caused a state error

from react-native-typewriter.

TaylorBriggs avatar TaylorBriggs commented on June 25, 2024

It just fires once when it reaches the end of it's children: https://github.com/TaylorBriggs/react-native-typewriter/blob/master/components/typewriter.js#L108

You have to pass a function to onTypingEnd. Right now you're passing a call to setState, which is why you're seeing the stack depth error. It would look something like this:

<TypeWriter typing={1} onTypingEnd={() => this.setState({ hasFinishedTyping: true })} />

from react-native-typewriter.

henriflouquet avatar henriflouquet commented on June 25, 2024

Thanks a lot for this lib ! Maybe it can help :
I have had the same issue even with passing a function and not a call to setState as suggested.
Solved it by updating the state only if prevstate was false, since calling set State in function was rerendering the component and calling onTypingEnd again (even though the typing occuring again)

from react-native-typewriter.

TaylorBriggs avatar TaylorBriggs commented on June 25, 2024

Just to clarify: are you saying the component starts typing again from an empty string on re-render? Once the typewriter component reaches the end of its children it should not start typing again unless its typing prop changes.

from react-native-typewriter.

henriflouquet avatar henriflouquet commented on June 25, 2024

sorry for the typo : the typing IS NOT occuring again

from react-native-typewriter.

TaylorBriggs avatar TaylorBriggs commented on June 25, 2024

I'm going to close this for now, as it doesn't seem to be a bug in the library itself. Feel free to re-open if you're still having a problem or if you have other questions. Thanks!

from react-native-typewriter.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.