React renderToString() Performance and Caching React Components

Using react-router1.0 and react0.14, we were mistakenly serializing our flux object multiple times. RoutingContext will call createElement for every template in your react-router routes. This allows you to inject whatever props you want. We also use flux. We send down a serialized version of a large object. In our case, we were doing flux.serialize() within … Read more

TypeScript error after upgrading version 4 useParams () from react-router-dom Property ‘sumParams’ does not exist on type ‘{}’

useParams is generic. You need to tell typescript which params you are using by specifying the value of the generic There are several ways to solve this This is my favorite way const { sumParams } = useParams<{ sumParams: string }>(); But there are a few more ways (: OR interface ParamTypes { sumParams: string; … Read more

Argument of type ‘HTMLElement | null’ is not assignable to parameter of type ‘Element’. Type ‘null’ is not assignable to type ‘Element’.ts(2345)

Other people have answered that you should add a null-check, but Typescript also has a non-null assertion that you can use when you are sure that the value is never null by adding the ! operator to the end of your statement: const portalDiv = document.getElementById(‘your-element’)!;

What’s the difference between hydrate() and render() in React 16?

From the ReactDOMServer docs (emphasis mine): If you call ReactDOM.hydrate() on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience. The text in bold is the main difference. render may change your node if there is a difference … Read more

React – Display loading screen while DOM is rendering?

The goal When the html page is rendered, display a spinner immediately (while React loads), and hide it after React is ready. Since the spinner is rendered in pure HTML/CSS (outside of the React domain), React shouldn’t control the showing/hiding process directly, and the implementation should be transparent to React. Solution 1 – the :empty … Read more

React vs ReactDOM?

React and ReactDOM were only recently split into two different libraries. Prior to v0.14, all ReactDOM functionality was part of React. This may be a source of confusion, since any slightly dated documentation won’t mention the React / ReactDOM distinction. As the name implies, ReactDOM is the glue between React and the DOM. Often, you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)