Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-remount

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-remount

A simple react HOC that inject a predifined key to ensure remount for the wrapped component when the key changed

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

react-remount

A simple component that injects a pre-defined prop as a key to the wrapped component, thus ensuring a re-mounting (a state reset) each time this prop is changed

NPM JavaScript Style Guide

Install

npm install --save react-remount

Usage

import React, { Component } from 'react';
import withRemount from 'react-remount';

class MyLib extends Component {
  render () {
    const {firstName, lastName} = this.props
    return (
      <div>{`Hello ${firstName} ${lastName}`}</div>
    )
  }
}

MyLib = withRemount(MyLib, 'firstName');
export default MyLib;

Now when ever we use MyLib, react-remount will inject the value of firstName as a key.

<MyLib firstName="John" lastName="Doe>

We can also pass a function to withRemount, as long as this function returns a string.
This is helpful when you want to chain multiple props as your key:

MyLib = withRemount(MyLib, props => props.firstName + props.lastName);

License

MIT © sag1v

Keywords

FAQs

Package last updated on 03 Feb 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc