Using JQuery plugins that transform the DOM in React Components?

前端 未结 4 637
梦毁少年i
梦毁少年i 2020-11-29 17:42

Some JQuery plugins don\'t just add behavior to DOM nodes, but change them. For example, Bootstrap Switch turns

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 18:32

    In this great ryanflorence's tutorial you'll get an idea on how to do this:

    Wrapping DOM Libs

    Methodology

    1. DOM libs usually manipulate the DOM
    2. React tries to re-render and finds a different DOM than it had last time and freaks out
    3. We hide the DOM manipulation from React by breaking the rendering tree and then reconnecting around the DOM the lib manipulates.
    4. Consumers of our component can stay in React-land.

提交回复
热议问题