/* eslint-disable eslint-multitab-tt/set-global-only-variable */ import type { FC } from '../../lib/teact/teact'; import React from '../../lib/teact/teact'; import { getGlobal, setGlobal, withGlobal } from '../../global'; import type { GlobalState } from '../../global/types'; document.ondblclick = () => { const value = Math.random(); setGlobal({ ...getGlobal(), // @ts-ignore bValue: value, aValue: value, }); }; type AStateProps = Pick & { aValue: number; }; type BStateProps = Pick & { bValue: number; derivedAValue: number; }; type BOwnProps = Pick & { aValue: number; }; const TestB: FC = ({ bValue, aValue, derivedAValue }) => { // eslint-disable-next-line no-console console.log('!!! B MOUNT ', { bValue, aValue, derivedAValue }); return (

B

bValue = {bValue}
aValue = {aValue}
derivedAValue = {derivedAValue}
{bValue > 0.5 ? ( Hello ) : ( World )}
); }; const TestBContainer = withGlobal( (global, { aValue }): BStateProps => { // eslint-disable-next-line no-console console.log('!!! B MAP', { aValue }); return { // @ts-ignore bValue: global.bValue, derivedAValue: (aValue || 0) + 1, }; }, )(TestB); const TestA: FC = ({ aValue }) => { // eslint-disable-next-line no-console console.log('!!! A MOUNT ', { aValue }); return (

A

aValue = {aValue}
); }; export default withGlobal( (global): AStateProps => { // @ts-ignore // eslint-disable-next-line no-console console.log('!!! A MAP', { aValue: global.aValue }); return { // @ts-ignore aValue: global.aValue, }; }, )(TestA);