-
git clone https://github.com/kintone-workshops/kintone-react-search-bar
- Inside Kintone_React_Search_Bar, run
npm install
-
npm install -g @kintone/customize-uploader
- Log into your Kintone Subdomain
- Create a Kintone App
- Add text fields for
title
andauthor
- Create a Custom View
- Get the View ID
- Add text fields for
- Input sample data
- Create
.env
using.env.example
as a template - Fill out the
.env
file- KINTONE_BASE_URL is set as "https://example.kintone.com"
- KINTONE_USERNAME & KINTONE_PASSWORD
- Add the View ID from earlier to VIEW_ID
- Update
customize-manifest.json
with App ID
- src/index.js
- src/components/SearchBar.js
- src/components/ResultList.js
See Complete the Code section for details
- Verify 3) Project Setup steps are completed
- Run
npm run start
Some ideas to further build out the project:
- Production build -> Package.json
- Click on the search result -> go to record detailed view
- Button to clear search results
- Include Alternative title field data
- The
handleChange
function takes in the browser-generated event object and thelistItems
. - The user input stored in the event object is used to compare with the title field.
filter()
accepts a function as a parameter.- That function acts as a condition to evaluate each item in the array as true-or-false.
filter()
then returns an array of items passing that condition.
- Conclude by setting
setSearchResults(filterResults)
Incomplete Version
const handleChange = e => { // e is a typical way to name the browser-generated event object
let filterResults;
console.log('filterResults: \n', filterResults);
setSearchResults(filterResults);
};
Completed Version
const handleChange = e => { // e is a typical way to name the browser-generated event object
let filterResults = listItems.filter(record =>
record.title.toLowerCase().includes(e.target.value.toLowerCase()) // filter condition
);
console.log('filterResults: \n', filterResults);
setSearchResults(filterResults);
};
- Complete the
<input />
element to build the search bar className='SearchBar'
onChange={props.handleChange}
Incomplete Version
className=''
...
onChange={props.handleChange}
Completed Version
className='SearchBar'
type='text'
id='header-search'
placeholder='Search Manga Titles'
name='Search Bar for Manga Titles'
onChange={props.handleChange}
- Finishing the ResultList component to output the list of records by using map function on searchResults
{props.searchResults.map(function (resultRecord) {})}
- Inside we would return JSX: return
<li key={resultRecord.uniqueKey}>{resultRecord.title} written by {resultRecord.author}</li>
Incomplete Version
export default function ResultList(props) {
return (
<div className='ResultList'>
</div>
);
};
Completed Version
export default function ResultList(props) {
return (
<div className='ResultList'>
<ul>
{props.searchResults.map(function (resultRecord) {
return (
<li key={resultRecord.uniqueKey}>
{resultRecord.title} written by {resultRecord.author}
</li>
)
})}
</ul>
</div>
);
};