我想呈現一個組件,但值是在一個jQuery函數內檢查輸入字段中的更改。ReactJS使用jQuery的動畫
控制檯返回此錯誤:
Objects are not valid as a React child (found: [object HTMLDocument]). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of
Result
代碼:
import React, { Component } from 'react';
import Result from './Result';
import * as $ from 'jquery';
import ReactFM from '../lib/ReactFM';
import { config } from '../config';
export let reactfm = new ReactFM(config.apiKey);
let name = $(() => {
$('.input-search').keypress(() => {
let inp = $('.input-search').val();
return reactfm.searchArtists(inp);
});
});
class SearchResults extends Component {
render() {
return (
<div className="search-results">
<Result avatar="" name={name} desc="um deus" />
</div>
);
}
}
export default SearchResults;
'returns reactfm.searchArtists(inp)'return? – jmargolisvt
從lastfm api提取的名稱 –
請將您的結果組件添加到您的問題。 – jmargolisvt