Code Monkey home page Code Monkey logo

Comments (4)

gaogaotiantian avatar gaogaotiantian commented on August 17, 2024

这个重复调用引入了任何bug么?在前端的世界里反复渲染不是一个罪大恶极的事,有的时候如果可以让代码变得更加简单,更“stateless”,反而是更好的设计。也就是说,渲染本身总是完全渲染,并不依赖之前的状态,任何时刻,给了同样的数据,渲染出的总是同样的界面。

只有在performance真的开始出问题的时候,这才开始成为一个问题,然后再去考虑怎么优化。一个函数被反复调用这件事不是啥大事。

from biliscope.

F-park avatar F-park commented on August 17, 2024

确实,这个不是 bug。但我觉得还是有必要重构这个函数的,updateData 现在的可读性和可维护性太差了。 如果其中调用的函数出现了 biliGet 或者 biliPost 函数,那就会出现大问题了。

from biliscope.

gaogaotiantian avatar gaogaotiantian commented on August 17, 2024

有很多函数如果它里面调用了不该调用的函数都会出大问题啊,这不是理由。你任何一个函数,在没有处理好的情况下调用自己都可能产生无限递归。

updateData就是把数据渲染成html的过程,有了数据,画图,这是一个非常清晰的概念,并且是stateless的,任何情况下,有什么data就渲染什么前端。加上state显然是把程序变得更加复杂了。

from biliscope.

F-park avatar F-park commented on August 17, 2024

那就不重构了吧,但是还是可以把意料之外的调用给修改掉。

from biliscope.

Related Issues (20)

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.