react-component-visible
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-component-visible

react-component-visible is a React library to handle conditional rendering very gracefully.

Installation

Use the package manager npm or yarn to install react-component-visible.

npm install react-component-visible

or

yarn install react-component-visible

Usage

import React from 'React';
import Visible from "react-component-visible";

const App = () => {
  const [isLoaded, setIsLoaded] = useState(false);
  
  useEffect(() => {
    setTimeout(() => {
      setIsLoaded(true);
    }, 3000);
  }, []);

  return (
    <div className="App">
      <header className="App-header">
        <Visible when={isLoaded} fallBack={"Please wait..."}>
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.tsx</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </Visible>
      </header>
    </div>
  );
}

export default App;

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Readme

Keywords

none

Package Sidebar

Install

npm i react-component-visible

Weekly Downloads

8

Version

1.0.0

License

ISC

Unpacked Size

3.37 kB

Total Files

6

Last publish

Collaborators

  • umang2226