Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-component-strategy-map
Advanced tools
React component for rendering out components based on key value pair
A react component for rendering the correct component from a strategy map based on the given key.
Add to your package.json
:
yarn add react-component-strategy-map
Import and use:
import { RenderComponentStrategy } from 'react-component-strategy-map';
const componentStrategyMap = {
someKey: SomeComponent,
someOtherKey: SomeOtherComponent,
};
const MainComponent = () => (
<RenderComponentStrategy
componentStrategy={componentStrategyMap}
componentKey="someKey"
renderDefault={() => <div>Rendered default</div>}
/>
);
Prop | Optional | Type | Default | Description |
---|---|---|---|---|
componentStrategy | false | {[key: string]: React.ComponentType} | {} | Map of components used to render based on the given "componentKey" |
componentKey | false | string | "" | key to the desired component to render from "componentStrategy" |
componentProps | true | object | {} | And object of props to spread onto the rendered component |
renderDefault | true | React.ComponentType | null | React component to render if "componentKey" does not match a key in "componentStrategy". If no default is given, component will return null |
FAQs
React component for rendering out components based on key value pair
We found that react-component-strategy-map 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.