40 | {!this.state.clicked ? "Hi" : "Hey"}
41 | {this.state.clicked &&
}
42 |
43 | );
44 | }
45 | }
46 |
47 | export default ReactClass;
48 |
--------------------------------------------------------------------------------
/__tests__/react-class.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable import/no-unresolved, import/no-extraneous-dependencies */
2 | import React, { Component } from "react";
3 | import PropTypes from "prop-types";
4 | import { Stylesheet } from "react-native";
5 | import type { SyntheticEvent } from "react-native/Libraries/Types/CoreEventTypes.js";
6 |
7 | class ReactClass extends Component {
8 | static propTypes = {
9 | onMount: PropTypes.func,
10 | };
11 |
12 | constructor(props) {
13 | super(props);
14 | }
15 |
16 | state = {
17 | clicked: false,
18 | };
19 |
20 | componentDidMount() {
21 | if (this.props.onMount) {
22 | this.props.onMount();
23 | }
24 | }
25 |
26 | handleClick = (event: SyntheticEvent<*>) => {
27 | event.preventDefault();
28 |
29 | this.setState({ clicked: true });
30 | };
31 |
32 | render() {
33 | return (
34 |