Why shouldn’t I use jQuery in React?

  • what you could do in theory is move the state outside of react in something like redux.
  • so JQuery does something -> statecontainer gets the update -> react will do something accordingly.
  • in theory react is just a view library, so you could use jquery to build your framework and render everything with react still react can only “see and hear” what’s happening in react.
  • it’s functional so it does not care about the global state unless you patch it in.
  • I would not use jQuery in react unless it’s really necessary, which it’s probably not.

Almost everyone is saying: »Don’t use jQuery in React!«
But they don’t really explain why. They just say don’t use it. I haven’t found any good reasons yet. No problem to use it! Example: VS Don’t use it! Why:.
Continue reading “Why shouldn’t I use jQuery in React?”

Lazy Loaded React Components With Webpack 2

Lazy loaded #ReactJS components with #Webpack 2:

  • How to improve your React code-base with higher order components (HOC) and how to make parts of your single page application load on-demand with Webpack 2.
  • Because Webpack searches the code for and creates new chunks depending on the path argument.
  • We the file needs to look like this:

    Now is able to create our wrapping component (WC) and give it access to the function that will load the right import.

  • The promise will resolve to our loaded module and this should export a React component as default.
  • When default export, the real component (RC) we really want to render is stored in the state of the WC, the WC will render again, this time with the RC and pass its down to it, so the parent of WC won’t be the wiser about what happened.

Making components load on-demand with Webpack 2.
Continue reading “Lazy Loaded React Components With Webpack 2”