react#ReactFragment TypeScript Examples

The following examples show how to use react#ReactFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Navigation.tsx    From next-cms-ghost with MIT License 6 votes vote down vote up
Navigation = ({ data, navClass }: NavigationProps) => {
  const items: ReactFragment[] = []

  data?.map((navItem, i) => {
    if (navItem.url.match(/^\s?http(s?)/gi)) {
      items.push(
        <li key={i} className={`nav-${navItem.label.toLowerCase()}`} role="menuitem">
          <a className={navClass} href={navItem.url} target="_blank" rel="noopener noreferrer">
            {navItem.label}
          </a>
        </li>
      )
    } else {
      items.push(
        <li key={i} className={`nav-${navItem.label.toLowerCase()}`} role="menuitem">
          <div className={navClass}>
            <Link href={navItem.url} >
              <a>{navItem.label}</a>
            </Link>
          </div>
        </li>
      )
    }
  })

  return (
    <ul className="nav" role="menu">
      {items}
    </ul>
  )
}
Example #2
Source File: VideoActions.tsx    From tik-tok-clone with MIT License 6 votes vote down vote up
function VideoAction(props: { children: ReactFragment; count: number }) {
  return (
    <div
      style={{
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        fontWeight: 'bold',
        fontSize: '.8em',
        marginTop: 20,
      }}
    >
      <div
        style={{
          cursor: 'pointer',
        }}
      >
        {props.children}
      </div>
      <div
        style={{
          marginTop: 5,
        }}
      >
        {props.count}
      </div>
    </div>
  );
}
Example #3
Source File: listurls.tsx    From Uptimo with MIT License 5 votes vote down vote up
ListUrls = ({ urls }: any) => {
  const { data, error } = useSWR(`http://localhost:3000/api/v1/urls`, fetcher);
  const [infoAlert, setInfoAlert]: any = useState({ nothing: true });

  const deleteUrl = async(url: string) => {
    const test = await hyttpo.request({
      method: 'DELETE',
      url: `${window.location.origin}/api/v1/delete`,
      body: JSON.stringify({
        url
      })
    }).catch(e => e);

    setInfoAlert({ message: `URL ${url} has been deleted!` })
  }

  return (
    <div>
        { !infoAlert.nothing ? <div className="notification is-primary is-light">
        { infoAlert.message }
        </div> : '' } 
      { data ? <>
        <table className="table">
          <thead>
            <tr>
              <th>URL</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>
            { data.message.map((url: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined, index: number) => <>
              <tr key={`a${index}`}>
                <td key={`b${index}`}><a href={url as string} key={`d${index}`}>{url}</a></td>
                <td key={`c${index}`}>
                  <button className="button is-small is-danger is-light" onClick={() => deleteUrl(url as string)} key={`e${index}`}>DELETE</button>
                </td>
              </tr>
            </>) }
          </tbody>
        </table>
      </> : 'Loading...' }
    </div>
  )
}