New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

strummer-prop-types

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

strummer-prop-types

Use strummer schemas as react prop types

0.0.1
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Strummer Prop Types

Use strummer schemas as react prop types

JavaScript Style Guide stability-experimental Build Status

Why

  • Can share custom validators between server and client
  • Can do more complex validation out of the box (e.g. min and max length of a string)

Usage

import { Component } from 'react'
const s = require('strummer')
const sPropTypes = require('strummer-prop-types')

class MyComponent extends Component {
  render () {
    return (
      <div>{this.props.message}</div>
    )
  }
}

MyComponent.propTypes = sPropTypes({
  message: s.string()
})

export default MyComponent

or with a HOC

import { Component } from 'react'
const s = require('strummer')
const { WithProps } = require('strummer-prop-types')

class MyComponent extends Component {
  render () {
    return (
      <div>{this.props.message}</div>
    )
  }
}

const schema = {
  message: s.string()
}

export default WithProps(MyComponent, schema)

TODO

Add some tests

Keywords

react

FAQs

Package last updated on 02 Nov 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