Giter VIP home page Giter VIP logo

Comments (8)

beepcode avatar beepcode commented on July 16, 2024

Seems to have been added to the readme already:

<a onClick={() => go(1)}>

from react-morph.

hongbo-miao avatar hongbo-miao commented on July 16, 2024

Hi @beepcode, sorry for not clear. I mean using in user’s own function like the handleGo in the above code.

from react-morph.

beepcode avatar beepcode commented on July 16, 2024

Ok, the simplest solution would be to pass the go() function as a parameter. This would look like so:

handleGo = (go) => { go(); }

...

<a onClick={() => this.handleGo(go)}>

from react-morph.

hongbo-miao avatar hongbo-miao commented on July 16, 2024

Thanks, @beepcode , that is what I thought.

But <a onClick={() => this.handleGo(go)}> will causing rerender, right?

If it is, maybe the author can export something like below to help avoid rerender?

import { morphGo } from "react-morph";

handleGo = () => {
  morphGo();
  // something else
}

from react-morph.

beepcode avatar beepcode commented on July 16, 2024

You could use the lifecycle method "shouldComponentUpdate()" to prevent rerender.

from react-morph.

hongbo-miao avatar hongbo-miao commented on July 16, 2024

Thanks, I get it.
Hope the package can handle those things. Better experience for the rest of people.

from react-morph.

beepcode avatar beepcode commented on July 16, 2024

What are you trying to achieve exactly? Which "business case" are you trying to find a solution to? From my perspective the sole purpose of "go()" is to start the morph, so rerender is expected. Or are you trying to trigger the morph from outside?

from react-morph.

hongbo-miao avatar hongbo-miao commented on July 16, 2024

Oh, you are right! I forget rerender is necessary in this case for the animation. My bad.

from react-morph.

Related Issues (18)

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.