React-search basic example

瘦欲@ 提交于 2020-01-25 03:51:17

问题


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:

Any ideas?


回答1:


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?



来源:https://stackoverflow.com/questions/49183231/react-search-basic-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!