Rew
Rew

Reputation: 175

React-search basic example

I'm trying to get react-search to work in my Meteor app. This is my main App.js in the imports folder:

import Search from 'react-search';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
...
class App extends Component {
...
render() {
let items = [
  { id: 0, value: 'ruby' },
  { id: 1, value: 'javascript' },
  { id: 2, value: 'lua' },
  { id: 3, value: 'go' },
  { id: 4, value: 'julia' }
]
console.log(items)

return (
  <div class="">  
    <Search items={items} />
  ...
  </div>
);
}
}

Once I insert the <Search items={items} /> my app stops working and I get the following console errors:

enter image description here

Any ideas?

Upvotes: 1

Views: 765

Answers (1)

FisNaN
FisNaN

Reputation: 2865

I take a look on their source code: https://github.com/StevenIseki/react-search/blob/master/src/Search.js

import React, { Component, PropTypes } from 'react'

React had a break change where PropTypes is no longer inside the react package.
It's in prop-types package now. eg: import PropTypes from 'prop-types'

If you still want to use this package, you have to match the dependency in https://github.com/StevenIseki/react-search/blob/master/package.json

However, the implementation for this package isn't hard. So you highly recommend you create your own component based on their code if needed.

Does this help?

Upvotes: 1

Related Questions