
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
global-component
Advanced tools
import {Global} from "global-component";
function Main({children}) {
const {setExtend} = useContext(Global)
useEffect(() => {
const doSomething = () => {
// doSomething...
}
const someVar = {
// defineSomthing
}
setExtend({doSomething, someVar})
}, [])
return children
}
function Component(props) {
const {extend} = useContext(Global)
const {doSomething, someVar} = extend
doSomething()
return <></>
}
import Master, {Global} from "global-component";
import Button from "@mui/material/Button";
function App() {
const {openTip} = useContext(Global)
return <Button onClick={() => {
openTip("好椰")
}}>
click
</Button>
}
ReactDOM.render(
<React.StrictMode>
<Master>
<App/>
</Master>
</React.StrictMode>
,
document.getElementById('root')
);

默认使用 mui5 的相关组件,不继承自定义的mui theme,可自定义
import Master, {GlobalTip} from "global-component";
function Tip(props: GlobalTip) {
const {
open,
autoHideDuration,
type,
info,
onClose//用于将open set为false的函数 无需定义,使用即可
} = props
return <div className={'tip'}>
{open ? <>content here</> : ""}
<input type={"button"} onClick={() => onClose()}>关闭</input>
</div>
}
ReactDOM.render(
<React.StrictMode>
<Master Tip={Tip}>
<App/>
</Master>
</React.StrictMode>
,
document.getElementById('root')
);
FAQs
support some common global component api use react and mui5
We found that global-component 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
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.