Git Product home page Git Product logo

evolution's Introduction

evolution

A note on the evolution of important versions of popular front-end libraries/frameworks.

Node.js

React

  • ReactDOM.render is no longer supported in React 18.
// Before
import { render } from 'react-dom';
render(<App tab="home" />, document.getElementById('app'));

// After
import { createRoot } from 'react-dom/client';
const root = createRoot(document.getElementById('app')); // createRoot(document.getElementById('app')!) if you use TypeScript
root.render(<App tab="home" />);
  • changed unmountComponentAtNode to root.unmount.
// Before
unmountComponentAtNode(container);

// After
root.unmount();
  • removed the callback from render.
// Before
const container = document.getElementById('app');
render(<App tab="home" />, container, () => {
  console.log('rendered');
});

// After
function AppWithCallbackAfterRender() {
  useEffect(() => {
    console.log('rendered');
  });

  return <App tab="home" />
}

const root = createRoot(document.getElementById('app'));
root.render(<AppWithCallbackAfterRender />);
  • Finally, if your app uses server-side rendering with hydration, upgrade hydrate to hydrateRoot.
// Before
import { hydrate } from 'react-dom';
hydrate(<App tab="home" />, document.getElementById('app'));

// After
import { hydrateRoot } from 'react-dom/client';
const container = ;
const root = hydrateRoot(
  document.getElementById('app'),
  <App tab="home" />
);
// Unlike with `createRoot`, you don't need a separate root.render() call here.
  • React Hooks
    • Basic Hooks: useState, useEffect, useContext
    • Additional Hooks: useReducer, useCallback, useMemo, useRef, useImperativeHandler, useLayoutEffect, useDebugValue, useDeferredValue, useTransition, useId
    • Library Hooks: useSyncExternalStore, useInsertionEffect

Express

WARNING:This version was released in November 2014, but is still in beta as of today.

remove:

  • app.del - use app.delete`
  • req.acceptsCharset - use req.acceptsCharsets
  • req.acceptsEncoding - use req.acceptsEncodings
  • req.acceptsLanguage - use req.acceptsLanguages
  • res.json(obj, status) signature - use res.json(status, obj)
  • res.jsonp(obj, status) signature - use res.jsonp(status, obj)
  • res.send(body, status) signature - use res.send(status, body)
  • res.send(status) signature - use res.sendStatus(status)
  • res.sendfile - use res.sendFile instead
  • express.query middleware

change:

  • req.host now returns host (hostname:port) - use req.hostname for only hostname
  • req.query is now a getter instead of a plain property

add:

  • app.router is a reference to the base router
  • Add express.raw to parse bodies into Buffer
  • Add express.text to parse bodies into string
  • Add express.json and express.urlencoded to parse bodies
  • Add next("router") to exit from router

evolution's People

Contributors

baooab avatar

Watchers

 avatar  avatar

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.