React Wrapper Take 2 (#310)

This commit is contained in:
Steve Faulkner
2020-11-12 20:10:59 -06:00
committed by GitHub
parent 4ce9dcc024
commit d880723be9
6 changed files with 475 additions and 444 deletions

20
src/koComment.tsx Normal file
View File

@@ -0,0 +1,20 @@
/* eslint-disable react/prop-types */
import React, { useEffect, useRef } from "react";
export const KOCommentIfStart: React.FunctionComponent<{ if: string }> = props => {
const el = useRef();
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(el.current as any).outerHTML = `<!-- ko if: ${props.if} -->`;
}, []);
return <div ref={el} />;
};
export const KOCommentEnd: React.FunctionComponent = () => {
const el = useRef();
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(el.current as any).outerHTML = `<!-- /ko -->`;
}, []);
return <div ref={el} />;
};