
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
create-react-factory
Advanced tools
create-react-factory create a factory for your react component. It allows you to:
npm install create-react-factory
// Underline.js
import React from 'react'
import createReactFactory from 'create-react-factory'
export const Underline = ({component: Component = 'div', style = {}, ...props}) => (
<Component style={{...style, textDecoration: 'underline'}} {...props} />
)
export default Underline
export const factory = createReactFactory(Underline)
// Strong.js
import React from 'react'
import createReactFactory from 'create-react-factory'
export const Strong = ({component: Component = 'div', style = {}, ...props}) => (
<Component style={{...style, fontWeight: 'bold'}} {...props} />
)
export default Strong
export const factory = createReactFactory(Strong)
// Red.js
import React from 'react'
import createReactFactory from 'create-react-factory'
const Red = ({component: Component = 'div', style = {}, ...props}) => (
<Component style={{...style, color: 'red'}} {...props} />
)
export default Red
export const factory = createReactFactory(Red)
// RedStrongUnderline.js
import {factory as strongFactory} from './Strong'
import {factory as redFactory} from './Red'
import Underline from './Underline'
export const RedStrongUnderline = strongFactory(redFactory(Underline))
export default RedStrongUnderline
import React from 'react'
import {render} from 'react-dom'
import Rsu from './RedStrongUnderline'
render(<ul><Rsu component="li">Hello World!</Rsu></ul>, document.getElementById('root'))
// output:
// <ul>
// <li style="color: red; font-weight: bold; text-decoration: underline;">
// Hello World!
// </li>
// </ul>
Because with the "traditional" factory approach, the component property is overridden by the Component passed to the factory. Thus it become impossible to set a different component to render.
FAQs
React component factory factory
The npm package create-react-factory receives a total of 0 weekly downloads. As such, create-react-factory popularity was classified as not popular.
We found that create-react-factory 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.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.