Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@untool/react
Advanced tools
@untool/react
@untool/react
provides all three types of @untool/core
mixins. Its core
mixin uses @untool/webpack
's configureWebpack
hook to add some settings specific to React, for example support for JSX syntax.
Its runtime
, i.e. browser
and server
, mixins are a bit more interesting as they are untool
's only default render
mixins. They set up React for client- and server-side rendering. Additionally, they provide mixin hooks of their own to allow you to add your own features, for example Redux support.
$ yarn add @untool/react # OR npm install @untool/react
render([req, res, next])
(override)This method is being called from within @untool/core
whenever you call its render
method. In a server-side, i.e. Node.js, environment it receives the usual arguments any Express middleware receives: req
, res
, and next
. In a client-side, i.e. browser, environment it receives no arguments whatsoever.
const { Mixin } = require('@untool/core');
module.exports = class FooMixin extends Mixin {
render(req, res, next) {
if (req) {
// server
} else {
// browser
}
}
};
You will not usually have to override this method as it exposes the following mixin hooks to alter its behaviour. In a server-side environment, a fresh mixinable
container is being created for every request, including new mixin instances.
bootstrap([req, res])
(parallel)Within this method, you are expected to set up your application. Your implementation will receive both Express' req
and res
objects for you to do whatever you like with. If you need to do something asynchronous in this method, just return a Promise
.
const { Mixin } = require('@untool/core');
module.exports = class FooMixin extends Mixin {
bootstrap(req, res) {
if (req) {
// server
} else {
// browser
}
}
};
Remember you can register custom middlewares using @untool/express
instead of implementing elaborate request or response handling logic inside your runtime mixin.
enhanceElement(element)
(compose)With this method, you can wrap the React root element with additional components, like Redux' Provider. If you need to do something asynchronous in this method, just return a Promise
resolving to the wrapped element.
const { Mixin } = require('@untool/core');
module.exports = class FooMixin extends Mixin {
bootstrap(element) {
return element;
}
};
fetchData(data, element)
(pipe)Most applications need some sort of data. Implement this method in your mixin, to fetch said data before rendering and return an object with that additional data. If you need to do something asynchronous in this method, just return a Promise
resolving to the data.
const { Mixin } = require('@untool/core');
module.exports = class FooMixin extends Mixin {
fetchData(data, element) {
return { ...data, foo: 'bar' };
}
};
FAQs
untool react mixin
The npm package @untool/react receives a total of 159 weekly downloads. As such, @untool/react popularity was classified as not popular.
We found that @untool/react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.