Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

starfield-react

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

starfield-react

A React component that draws a Starfield on a canvas dom element.

  • 3.1.0-dev-3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126
increased by35.48%
Maintainers
1
Weekly downloads
 
Created
Source

Starfield

A retro Star Field Space effect in a html canvas element through a React Component and or Hook.

See a live editable demo here:

Edit starfield-react example

Install from npm:

`npm install starfield-react`
`yarn add starfield-react`

2) Use the React Component StarField directly in your React app:

import { StarField } from 'starfield-react'
import { render } from 'react-dom'

render(<StarField/>, document.querySelector('body'))

Or use the React Hook useStarField to have more control:

import { useStarField } from 'starfield-react'

const StarFieldCustom = (props) => {
  const canvasRef = useRef<HTMLCanvasElement>(null)
  const stateReference = useRef<StarFieldState>(createStarsState({
    count,
    height,
    width,
  }))

  // The same hook used in the `StarField` component above:
  useStarField(canvasRef, options, stateReference)

  return <canvas
    ref={canvasRef}
    {...{ width, height }}
    {...restProps}
  />
}

Documentation on the StarField Component props are on the Props interface type in src/StarField.tsx.

Examples of different props in action:

Keywords

FAQs

Package last updated on 08 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc