New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-lrc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-lrc

The react native component that display lyric from lrc format. Inspired by [Mebtte's react-lrc](https://github.com/mebtte/react-lrc)

latest
Source
npmnpm
Version
1.0.0-beta.1
Version published
Maintainers
1
Created
Source

react-native-lrc version license

The react native component that display lyric from lrc format. Inspired by Mebtte's react-lrc

Feature

  • Pure javascript, cross platform
  • Auto scroll smoothly
  • User srcollable
  • Custom style

Requirement

  • react >= 16.8 with hook
  • If used on browser react-native-web >= 0.11

Usage

npm install --save react-native-lrc
import React, { useCallback } from 'react';
import { Text } from 'react-native';
import { Lrc } from 'react-native-lrc';

const Lyric = ({ lrc, currentTime }) => {
  const lineRenderer = useCallback(
    ({ lrcLine: { millisecond, content }, index, active }) => (
      <Text
        style={{ textAlign: 'center', color: active ? 'green' : 'inherit' }}>
        {content}
      </Text>
    ),
    [],
  );
  const onCurrentLineChange = useCallback(
    ({ lrcLine: { millisecond, content }, index }) =>
      console.log(index, millisecond, content),
    [],
  );

  return (
    <Lrc
      style={{ height: 500 }}
      lrc={lrc}
      currentTime={currentTime}
      lineHeight={16}
      lineRenderer={lineRenderer}
      onCurrentLineChange={onCurrentLineChange}
    />
  );
};

export default Lyric;

Lrc Props

propdescriptiontypedefault
lrclrc stringstringrequired
lineRendererlrc line render method({ lrcLine: { id: string, millisecond: number, content: string }, index: number, active: boolean }) => ReactNode({ lrcLine: { content }, active }) => (<Text style={{ textAlign: 'center', color: active ? 'green' : '#666' }}>{content})
currentTimecurrent timenumber, millisecond0
autoScrollwhether auto scrollbooleantrue
autoScrollAfterUserScrollauto scroll after user scrollnumber, millisecond6000
onCurrentLineChangewhen current line change({ index: number, lrcLine: { id: string, millisecond: number, content: string } | null }) => voidnull
lineHeightlrc line heightnumber16
activeLineHeightactive lrc line heightnumberlineHeight
heightlrc container heightnumber500
other propsother react-native ScrollView Props--

Lrc Methods

methoddescriptiontype
scrollToCurrentLinescroll to current line and set auto scroll() => void
getCurrentLineget the current lrc line() => { lrcLine: { id: string, millisecond: number, content: string } | null, index: number }

Other API

parseLrc

import { parseLrc } from 'react-native-lrc';

parseLrc(lrcString); // { id: string, millesecond: number, content: string }[]

useLrc

import React from 'react';
import { useLrc } from 'react-native-lrc';

const Component = () => {
  const lrcLineList = useLrc(lrcString); // { id: string, millesecond: number, content: string }[]
  // ...
};

Question

Why lrc component do not auto scroll

You probably do not give height to Lrc. The height make Lrc scrollable.

How to prevent user scroll

<Lrc scrollEnabled={false} autoScrollAfterUserScroll={0} {...otherProps} />

Typescript

react-native-lrc export type LrcLine.

import React from 'react';
import { LrcLine } from 'react-native-lrc';

const Component = () => {
  const lineRenderer = React.useCallback(
    ({ lrcLine }: { lrcLine: LrcLine }) => {
      // ...
    },
    [],
  );
  // ...
  return <Lrc lineRenderer={lineRenderer} {...otherProps} />;
};

License

MIT

Keywords

react-native

FAQs

Package last updated on 18 Oct 2020

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