Exemple #1
0
             )

def Component5(props):
    ctx = useContext(Ctx)
    testVal = ctx['testVal']
    return el(Box, None,
              el(ROTextField, {'label': 'Copy From Row 1',
                              'value': testVal}
                ),
             )

def App():
    testVal, setTestVal = useState("")

    def handleChange(event):
        target = event['target']
        setTestVal(target['value'])

    return el(Ctx.Provider, {'value': {'testVal': testVal, 'otherVal': 42}},
              el(Box, {'key': 'App', 'style': {'width': '200px'}},
                 el(TextField, {'label': 'Row 1',
                                'value': testVal,
                                'onChange': handleChange}
                   ),
                 el(Component2, None)
                )
             )

render(App, None, 'root')

Exemple #2
0
                    'squares': current['squares'],
                    'onClick': self.handle_click,
                }),
                element('div', {'className': 'game-status'}, status),
            ),
            element(
                'div',
                {'className': 'game-info'},
                'Move History',
                element('ol', None, moves),
            ),
        )


# Render the component in a 'container' div
render(Game, None, 'root')


def calculate_winner(squares):
    lines = [
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8],
        [0, 3, 6],
        [1, 4, 7],
        [2, 5, 8],
        [0, 4, 8],
        [2, 4, 6],
    ]

    for i, line in enumerate(lines):