Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Component: React.ComponentType;
data?: object;
};
const Plugin: React.FC = ({ id, Component, data }) => {
// Plugin API this
const api = useApi(id);
const props: API = {
...api,
data,
};
return ;
};
export default withErrorBoundary(Plugin, Crashed, captureException);
function useApi(id: string) {
const dispatch = useDispatch();
// Cache
const cache = useSelector(state => state.cache[id]);
const boundSetCache = React.useCallback(
(cache: object) => dispatch(setCache(id, cache)),
[dispatch, id],
);
// Data
const boundSetData = React.useCallback(
(data: object) => dispatch(setData(id, data)),
[dispatch, id],
);
import Crashed from './Crashed';
import { useApi } from '../../utils/useApi';
type Props = {
id: string;
Component: React.ComponentType>;
};
const Plugin: FC = ({ id, Component }) => {
// Create plugin API
const api = useApi(id);
return ;
};
export default withErrorBoundary(Plugin, Crashed, captureException);
const pageWrapper = (Page, toTitle = R.F) => {
const title = R.pipe(
toTitle,
R.unless(R.is(String), R.always('')),
R.trim,
capitalize,
)
const locationToProps = R.pipe(
R.converge(R.merge, [R.prop('payload'), R.pick(['pathname'])]),
R.converge(R.assoc('pageTitle'), [title, R.identity]),
)
return [withErrorBoundary(Page, undefined, onError), locationToProps]
}