Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
A dust helper to render React components.
Features:
dust-react provides the following ways of importing:
dust-react/lib
, which is also the main entry point when doing require('dust-react')
)dust-react/dist
)The module is the default export. If you're using CommonJS without babel transpiling import/exports, you'll need to explicitly reference the default export.
const dustHelperReact = require('dust-react').default;
dust-react works in both Node.js and AMD environments. Configuring the helper based on the environment allows loading modules in both contexts.
dustHelperReact(options: object)
Option | Type | Description |
---|---|---|
requireFn | Function | Required - The require function based on the environment |
globalContext | Object | Required - The global context object (global in Node.js and window in the browser) |
componentDir | String | Optional - An absolute path for requiring components in Node.js |
import dust from 'dustjs-linkedin';
import dustHelperReact from 'dust-react';
import path from 'path';
dust.helpers = dust.helpers || {};
dust.helpers.react = dustHelperReact({
requireFn: require,
globalContext: global,
componentDir: path.resolve(__dirname, '../component')
});
Param | Type | Description |
---|---|---|
component | String | Required - the path to require the module |
props | Object | optional - Properties to be passed to React.createElement |
namedExport | String | optional - Uses the default export if not specified |
The helper requires a reference to a react component as a string. This is what is used with the require function passed in when creating the helper.
<div id="module-mount">
{@react component="react-module" props=. /}
</div>
This equates to a require statement that looks like the following:
require('react-module');
(Note about AMD - all modules are loaded asynchronously, and the rjs optimizer is not yet supported)
Props can also be variadic, allowing you to pass in params to the helper that become React props.
<div id="module-mount">
{@react component="react-book" title='Boop' pages=10 /}
</div>
This is equivalent to:
React.createElement(ReactBook, { title: 'boop', pages: 10 });
By default, dust-react will use the default export of the module. You can optionally specify a named export as well.
<div id="module-mount">
{@react component="react-module" namedExport="example" props=. /}
</div>
This is equivalent to:
const component = require('react-module').example;
// or in ES6
import { example } from 'react-module';
Component paths can be either a relative path or a package path.
./local-component/example
(must start with a dot-slash)some-npm-module
Under the hood, every path to a component for AMD becomes a package path. Passing in a relative path will result in requiring the module without the ./
. This allows you to reference a local file for rendering server-side and reference the same file from your RequireJS baseUrl
.
The tests are written in Jest.
npm test
FAQs
Dust helper to render react components
The npm package dust-react receives a total of 3 weekly downloads. As such, dust-react popularity was classified as not popular.
We found that dust-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.