Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const SignInPanel = () => {
const value = useParameter(PARAM_KEY, null);
const [state, setState] = useState(Providers.globalProvider.state);
const emit = useChannel({
STORY_RENDERED: id => {
console.log('storyRendered', id);
},
[GETPROVIDER_EVENT]: params => {
emitProvider(state);
}
});
const emitProvider = loginState => {
emit(SETPROVIDER_EVENT, { state: loginState });
};
Providers.onProviderUpdated(() => {
setState(Providers.globalProvider.state);
emitProvider(Providers.globalProvider.state);
});
const ViewportTool = () => {
const [role, setRole] = useAddonState(ADDON_ID, 'myra_range_officer')
const emit = useChannel({
[STORY_RENDERED]: () => {
setTimeout(() => {
emit('role/change', role)
}, 100)
}
})
const handleChange = e => {
setRole(e.target.value)
emit('role/change', e.target.value)
}
return (
const Editor = ({ api }: { api: API }) => {
const emit = useChannel({});
const story = useCurrentStory();
const storyId = story && story.id ? story.id : '';
const [initialCode, setInitialCode] = useEditor();
const [metaData, setMetadata] = React.useState(null);
let previousSource = '';
const loadStoryCode = (sourceLoader: SourceLoaderInfo) => {
const sourceCode = sourceLoader.edition.source;
setMetadata(sourceLoader);
if (previousSource === sourceCode || initialCode[storyId]) {
return null;
}
previousSource = sourceCode;
const sourceSplitted = sourceCode.split('\n');
export const Panel = () => {
const [results, setState] = useAddonState(ADDON_ID, []);
const emit = useChannel({
[EVENTS.RESULT]: (newResults: Results) => setState(newResults),
});
return (
<content>
emit(EVENTS.REQUEST) },
{ title: 'setState', onClick: () => setState(['foo']) },
{
title: 'setState with options',
onClick: () => setState(['bar'], { persistence: 'session' }),
},
{ title: 'setState with function', onClick: () => setState(s => [...s, 'baz']) },</content>
export const CoverageTool: React.FunctionComponent<{}> = () => {
const [active, setActive] = useState(true);
const icon = active ? 'eye' : 'eyeclose';
window.getStoryColor = (storyId: string) => getColor(storyId, active);
const emit = useChannel({
[EVENTS.COVERAGE_SUMMARY]: (summary: CoverageSummary) => {
setCoverageSummary(summary);
},
});
return (
{
setActive(!active);
emit(SELECT_STORY, { kind: 'Coverage|Welcome', story: 'normal' });
}}
>