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

@wildberries/notifications

Package Overview
Dependencies
Maintainers
4
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wildberries/notifications

notifications module

  • 0.0.10-beta.3
  • npm
  • Socket score

Version published
Weekly downloads
738
decreased by-24.07%
Maintainers
4
Weekly downloads
 
Created
Source

@wildberries/notifications

Sollution for notifications, connected with redux

Examples of usage

Installation

npm install @mihanizm56/notifications

Connect to your root reducer

import {notificationsState} from '@wildberries/notifications';

export const rootReducer = {
  notificationsState,
  ...other root reducers
};

Insert the Notifications component into your project

import React, { memo } from "react";
import { Notifications, setModalAction } from "@wildberries/notifications";
import { createPortal } from 'react-dom';
import { uniqueId } from 'lodash-es'

const portalElement = document.getElementById('portal');

class Portal extends React.PureComponent{
  constructor(props) {
    super(props);

    this.containerEl = document.createElement('div');
    this.containerEl.id = `${props.prefix}_${uniqueId('id_')}`;
    portalElement.appendChild(this.containerEl);
  }

  componentWillUnmount() {
    this.containerEl.remove();
  }

  render() {
    return createPortal(this.props.children, this.containerEl);
  }
}

const TestComponent = memo(() => (
    <div className="TestComponent">
    <Portal prefix="notifications">
      <Notifications />
    </Portal>
    </div>
  );
})

Dispatch setModalAction to add notifications modal

SetModalAction params:
  • status - success | error - modal status (required)
  • text - string - modal test (required)
  • additionalPayload - string - payload of additional action if need to call from modal (not required)
  • additionalActionType - any - type of additional action if need to call from modal (not required)
import React from "react";
import { setModalAction } from "@wildberries/notifications";
import { uniqueId } from 'lodash-es'
import { useDispatch } from "react-redux";

function ExampleComponent) {
  const dispatch = useDispatch();

  const setModal = () => {
    dispatch(setModalAction({
      status: 'success',
      text: 'modal text',
      additionalPayload: { foo:'bar' }, 
      additionalActionType: 'SOME_TYPE',
    }))
  }

  return (
    <div className="ExampleComponent">
        <button onClick={setModal}>button</button>
    </div>
  );
}

export default App;

FAQs

Package last updated on 07 Aug 2020

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