You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Maintainers
1
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

react

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