react-slick icon indicating copy to clipboard operation
react-slick copied to clipboard

React.createElement: type is invalid -- expected a string but got :object

Open Webdevalan opened this issue 9 years ago • 4 comments

Trying to use this with a table and just regular DIVs for now:

import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import { Modal,ModalManager,Effect} from 'react-dynamic-modal';

var Slider = require('react-slick');

class MyModal extends Component{
   render(){
      const { text,onRequestClose } = this.props;
      return (
         <Modal
            style={{content:
              {
                overlay: {
                  position        : 'fixed',
                  top             : 0,
                  left            : 0,
                  right           : 0,
                  bottom          : 0,
                  zIndex          : 99999999,
                  overflow        : 'hidden',
                  perspective     :  1300,
                  backgroundColor : 'rgba(0, 0, 0, 0.3)'
                },


```                content: {
                  position                : 'relative',
                  margin                  : '15% auto',
                  width                   : '60%',
                  border                  : '1px solid rgba(0, 0, 0, .2)',
                  background              : '#fff',
                  overflow                : 'auto',
                  borderRadius            : '4px',
                  outline                 : 'none',
                  boxShadow               : '0 5px 10px rgba(0, 0, 0, .3)',
                }
              }
            }}
            onRequestClose={onRequestClose}
            effect={Effect.Newspaper}>
            <div className={'modal-header modal-header-info'}>
                    <button type="button" className="close" onClick={ModalManager.close} aria-hidden="true">×</button>
                    <h4><i className="glyphicon glyphicon-thumbs-up"></i> Source:</h4>
            </div>
            <div className={'modal-body'}>
              {text}
              </div>
            <div className={'modal-footer'}>
            <button className={'btn btn-sm btn-default'} onClick={ModalManager.close}>Close</button>
            </div>
         </Modal>
      );
   }
}

class JsonTable extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      posts: []
    };
  }

  componentDidMount() {
    axios.get(`http://www.reddit.com/r/${this.props.subreddit}.json`)
      .then(res => {
        const posts = res.data.data.children.map(obj => obj.data);
        this.setState({ posts });
      });
  }

      openModal(){
         const text = this.refs.input.value;
         ModalManager.open(<MyModal text={text} onRequestClose={() => true}/>);
      }

  render() {
    var settings = {
      dots: true,
      infinite: true,
      speed: 500,
      slidesToShow: 1,
      slidesToScroll: 1
    };
    return (
    	<div className='container'>
        <Slider {...settings}>
           <div>
             <div>
                <input type="text" placeholder="input something" ref="input" defaultValue="Stop using CSS in JavaScript for web development: How to style components in React." /> &nbsp;&nbsp;
                <button type="button" className={'btn btn-sm btn-primary glyphicon glyphicon-eye-open'} onClick={this.openModal.bind(this)}> View Source</button>
             </div>

            <h1>{` prop: ${this.props.subreddit}`}</h1>
            <ul>
              {this.state.posts.map(post =>
                <li key={post.id}>{post.title}</li>
              )}
            </ul>
          </div>
          <div><h3>2</h3></div>
        </Slider>
        </div>
    );
  }
}
`

Webdevalan avatar May 08 '17 02:05 Webdevalan

Your dependency should be imported like so: import Slider from 'react-slick';

OhCirca avatar May 10 '17 15:05 OhCirca

That worked! Thanks! Great carousel!!

Webdevalan avatar May 11 '17 04:05 Webdevalan

The docs should be updated then, I had this issue too.

mrtrandinhvn avatar Jun 06 '17 07:06 mrtrandinhvn

Works! please update the docs ;-)

afmarchetti avatar Sep 05 '17 08:09 afmarchetti