* @param {string} name * @returns {[import('preact').ComponentClass, import('preact').RefObject<{ toggle(): void }>]}
(name)
| 27 | * @returns {[import('preact').ComponentClass, import('preact').RefObject<{ toggle(): void }>]} |
| 28 | */ |
| 29 | function createStatefulNullable(name) { |
| 30 | let ref = createRef(); |
| 31 | class Nullable extends Component { |
| 32 | constructor(props) { |
| 33 | super(props); |
| 34 | this.state = { show: props.initialShow || true }; |
| 35 | ref.current = this; |
| 36 | } |
| 37 | toggle() { |
| 38 | this.setState({ show: !this.state.show }); |
| 39 | } |
| 40 | componentDidUpdate() { |
| 41 | ops.push(`Update ${name}`); |
| 42 | } |
| 43 | componentDidMount() { |
| 44 | ops.push(`Mount ${name}`); |
| 45 | } |
| 46 | componentWillUnmount() { |
| 47 | ops.push(`Unmount ${name}`); |
| 48 | } |
| 49 | render() { |
| 50 | return this.state.show ? <div>{name}</div> : null; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return [Nullable, ref]; |
| 55 | } |
| 56 | |
| 57 | let resetAppendChild; |
| 58 | let resetInsertBefore; |
no test coverage detected
searching dependent graphs…