mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-08 01:13:27 +01:00
29 lines
No EOL
458 B
JavaScript
29 lines
No EOL
458 B
JavaScript
import React from 'react';
|
|
|
|
const CONTRIBUTED_COMPONENTS = [];
|
|
|
|
const mounted = new Set();
|
|
|
|
export default class ContributedComponents extends React.Component {
|
|
|
|
|
|
componentDidMount() {
|
|
mounted.add(this);
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
mounted.delete(this);
|
|
}
|
|
|
|
render() {
|
|
return CONTRIBUTED_COMPONENTS;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function contributeComponent(comp) {
|
|
CONTRIBUTED_COMPONENTS.push(comp);
|
|
mounted.forEach(c => c.forceUpdate());
|
|
} |