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

preact-views

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preact-views

Connect your components up to that address bar.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

preact-views

NPM travis-ci

Named views for Preact, with easy-as-pie linking between them!

preact-views provides a <Views /> component that renders its children only when their name prop is selected as the current "view". The current view name can be set via a prop, or automatically through the provided <Link /> component.

Note: preact-views is simple and does not do orchestration or routing for you. If you're looking for a URL router, try preact-router.

See a Real-world Example :arrow_right:

Complete Example

import { Views, Link } from 'preact-views';
import { h, render } from 'preact';

const Home = () => (
	<div>
		<h1>Home!</h1>
		<Link to="other" params={{ value:1 }}>Go Other</Link>
	</div>
);

const Other = ({ value=0 }) => (
	<div>
		<h1>Other.</h1>
		<Link to="home">Go Home</Link>
		<p>value is {value}.</p>
		<Link to="other" params={{ value: value+1 }}>Increment</Link>
	</div>
);

render((
	<Views view="home">
		<Home name="home" />
		<Other name="other" />
	</Views>
), document.body);

See it running :arrow_right:

Simple Example

import Views from 'preact-views';
import { h, render } from 'preact';

render((
	<Views view="one">
		<div name="one">one</div>
		<div name="two">two</div>
	</Views>
), document.body);

// renders a div containing the text "one"

License

MIT

Keywords

preact

FAQs

Package last updated on 21 Feb 2017

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