Giter Site home page Giter Site logo

学习案例study.js about luy HOT 4 CLOSED

NotCoderJack avatar NotCoderJack commented on August 27, 2024
学习案例study.js

from luy.

Comments (4)

Foveluy avatar Foveluy commented on August 27, 2024 1

@gapsaras

问的很好,这个是React的一个难点,也是现在人都不怎么说的一个点。

如果facebook没有出jsx的话,我们用的就是createElement.js书写React。

<div className='shit'>
      asdasdasd
</div>

其实会被babel转换成

createElement('div',{className:'shit'},'asdasdasd')

.babelrc中,你会看见

 ["transform-react-jsx", {
      "pragma": "React.createElement" // 默认 pragma 为 React.createElement
    }],

这一句话,这句话就是帮助babel找到createElement函数的地方。

createElement非常重要,也是生成Vnode的地方。

如果喜欢这个项目,给项目一些星星,近期将会有大更新,支持ComponentDidCatch,以及render返回任意的数据类型

from luy.

NotCoderJack avatar NotCoderJack commented on August 27, 2024

@215566435 谢谢大神的及时回复,我的理解是:createElement会被babel使用,作为生成vnode的实现方法,相当于babel对外提供的一个可被用户覆盖的方法,不知是不是这样?

from luy.

Foveluy avatar Foveluy commented on August 27, 2024

@gapsaras 是的,没错。

from luy.

Foveluy avatar Foveluy commented on August 27, 2024

修复

from luy.

Related Issues (12)

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.