What's New in React v16.7
Not that lengthy ago, React v16.6 was released with a few pretty superb new features. Just in time for Christmas, the React group has released React v16.7 but now not with the big feature we had been all expecting to get our arms on over the holiday, Hooks.
Yes, even though Hooks have been supposed to aside of this version, even displaying up inside the latest alphas, it was determined to leave out the characters so that restoration for an unpleasant performance bug with React.Lazy() should be launched.
The motive in the back of doing a minor release without the addition of any new capabilities is that the patches that have been included inside the release had been considered non-trivial even though the forward-facing conduct didn’t change.
This consideration for what constitutes minor releases even goes for the parts of React that are prefixed with unstable_. Get more info To learn to React js Online Training
Oh, and React group is going to try to avoid pinning unreleased capabilities to specific versions of React. No extra getting out hopes up only to be permit down ;)
Even even though we need to wait for a chunk longer for Hooks, that doesn’t imply we can’t take benefit of a number of the improvements with this new version of React!
Fixes to React DOM
- Performance improved for handling a ton of lazy-loaded components with React.lazy()
- Fix for a performance regression while in profiling mode
- Fix for an issue with server-side rendering and context when using react-dom/server@16.6 with react@<16.6
- Memory leak avoidance by clearing fields on unmount
Learn more about React App to follow us Reactjs Training
Improvements and Fixes to Scheduler
Even although it’s still taken into consideration experimental, the React scheduler got some love:
- Post to MessageChannel in preference to the window to avoid a ton of useless calls to different message event handlers. Gracefully falls returned to using window while MessagteChannel isn’t available
- Reduction in overhead from serialization
- Debugging techniques added
- Fix for a fallback to setTimeout which also may cause the discharge of a new lib, jest-mock-scheduler within the future
Ready to get started with React v16.7?
Just go ahead and install it:
# Via npm
$ npm install --save react@^16.7.0 react-dom@^16.7.0
# Via Yarn
$ yarn add react@^16.7.0 react-dom@^16.7.0
Deprecating javascript: URLs
URLs starting with javascript: are a dangerous attack surface because it’s easy to accidentally include the unsanitized output in a tag like <a href> and create a security hole:
const userProfile = {
website: "javascript: alert('you got hacked')",
};
// This will now warn:
<a href={userProfile.website}>Profile</a>In React 16.9, this pattern continues to work, but it will log a warning. If you use javascript: URLs for logic, try to use React event handlers instead. (As a last resort, you can circumvent the protection with dangerouslySetInnerHTML, but it is highly discouraged and often leads to security holes.)
In a future major release, React will throw an error if it encounters a javascript: URL.