How to use the react-md/lib/Snackbars.defaultProps function in react-md

To help you get started, we’ve selected a few react-md examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mlaursen / react-md / documentation / src / shared / components / snackbars / InteractiveExample.jsx View on Github external
_addToast() {
    const { text, action } = this.state;
    const toasts = this.state.toasts.slice();
    toasts.push({ text, action });

    const words = text.split(' ').length;
    const autohideTimeout = Math.max(
      Snackbar.defaultProps.autohideTimeout,
      (words / AVERAGE_WPS) * 1000
    );

    this.setState({ toasts, autohideTimeout });
  }
github mlaursen / react-md / documentation / src / components / Components / snackbars / Interactive.jsx View on Github external
import React, { PureComponent } from 'react';
import Button from 'react-md/lib/Buttons/Button';
import Snackbar from 'react-md/lib/Snackbars';
import CardActions from 'react-md/lib/Cards/CardActions';
import TextField from 'react-md/lib/TextFields';
import SelectionControl from 'react-md/lib/SelectionControls/SelectionControl';

import './_interactive.scss';

export default class Interactive extends PureComponent {
  state = {
    toasts: [],
    text: 'Hello, World!',
    action: '',
    autohide: true,
    autohideTimeout: Snackbar.defaultProps.autohideTimeout,
  };

  handleSubmit = (e) => {
    e.preventDefault();
    const { text, action } = this.state;
    const toasts = this.state.toasts.slice();
    toasts.push({ text, action });

    this.setState({ toasts });
  };

  handleReset = () => {
    this.setState({
      text: '',
      action: '',
      autohide: true,
github mlaursen / react-md / documentation / src / components / Components / snackbars / Interactive.jsx View on Github external
handleReset = () => {
    this.setState({
      text: '',
      action: '',
      autohide: true,
      autohideTimeout: Snackbar.defaultProps.autohideTimeout,
      toasts: [],
    });
  };
github mlaursen / react-md / documentation / src / components / Components / snackbars / Interactive.jsx View on Github external
Toast
          
          <button type="reset" id="interactive-snackbar-reset">
            Reset
          </button>
        
        
      
    );
  }
}