Socket
Book a DemoInstallSign in
Socket

react-smart-sections

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-smart-sections

Vertical scroll solution that follows what you actually read

0.0.2
latest
npmnpm
Version published
Weekly downloads
269
333.87%
Maintainers
1
Weekly downloads
 
Created
Source

React Smart Sections

Vertical scroll solution that follows what you actually read

Installation

yarn add react-smart-sections
npm install --save react-smart-sections

Documentation

import { Fragment as 👻 } from 'react';
import { Section } from 'react-smart-sections';

export const Page = () => (
  <👻>
    <Section name="introduction">
      <h1>Introductin</h1>
      <p>By default Section wraps it's content with a div</p>
    </Section>
    <Section name="chapterOne" component="section">
      <h2>Chapter one</h2>
      <p>You can also provide component prop that specifies html tag rendered by Section</p>
    </Section>
    <Section name="chapterTwo" render={(handleRef) => (
      <YourWrapperComponent ref={handleRef}>
        <h2>Chapter two</h2>
        <p>You can also use your wrapping component as long as you provide a reference to a rendered DOM element</p>
      </YourWrapperComponent>
    )} />
  </👻>
);
import { SectionsSpy } from 'react-smart-sections';

const labels = {
  introduction: "Introduction",
  chapterOne: "Chapter one",
  chapterTwo: "Chapter two",
};

export const Navigation = () => (
  <nav>
    <ul>
      <SectionsSpy render={(sections) => (
        {sections.map(section => (
          <li key={section.name} className={section.active ? "active" : null}>
            <a href="#" onClick={section.scroll}>{labels[section.name]}</a>
          </li>
        ))}
      )} />
    </ul>
  </nav>
)
import { SectionSpy } from 'react-smart-sections';

export const Navigation = () => (
  <nav>
    <ul>
      <SectionSpy
        name="introduction"
        render={section => (
          <li className={section.active ? 'active' : null}>
            <a href="#" onClick={section.scroll}>
              Introduction
            </a>
          </li>
        )}
      />
    </ul>
  </nav>
);

FAQs

Package last updated on 09 Apr 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.