Skip to content

Instantly share code, notes, and snippets.

@liamdawson
Created July 27, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liamdawson/17e52e51d59069c72f25eb35949b3e20 to your computer and use it in GitHub Desktop.
Save liamdawson/17e52e51d59069c72f25eb35949b3e20 to your computer and use it in GitHub Desktop.
Type usage examples for octicons-react
import React from 'react';
// all of the icons are auto-completeable in IDE imports
import Octicon, {Globe, getIconByName} from '@githubprimer/octicons-react';
import {storiesOf} from '@storybook/react';
storiesOf('Icon', module)
// won't compile, icon prop required
.add('Empty icon', () => <Octicon />)
// won't compile, string not assignable, needs to be Icon<x, y>, or a StatelessComponent
.add('Passing invalid item', () => <Octicon icon="globe" />)
.add('Passing valid item', () => <Octicon icon={Globe} />)
.add('Passing valid item by string ref', () => <Octicon icon={getIconByName('globe')} />);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment