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 an animated Starfield on a canvas dom element.

  • 3.1.0-dev-5
  • latest
  • Source
  • npm
  • Socket score

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

Starfield

A classic Starfield Space animation effect rendered in a html canvas element. Can be used through a React Component or hook with a canvas reference.

The package is published on 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'))

The default prop values render a classic Starfield but can be tweaked as above and shown in /examples.

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

Or use the React Hook useStarField to have more control over the canvas reference:

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}
  />
}

Keywords

FAQs

Package last updated on 23 Mar 2021

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