access line information, line id number and onChanged event - reactjs

How can I get the line information and id number I want to edit.
Also how can I access the onChanged event?
Can you help me ?
I want to get the line information I want to edit.
I want to get the id number of the line I want to edit.
How can I access onChanged events? So how can I understand when textfield changes?
`
import React, { Component } from "react";
import Paper from '#material-ui/core/Paper';
import { EditingState,SearchState,IntegratedFiltering, GroupingState, IntegratedGrouping,} from '#devexpress/dx-react-grid';
import { ColumnChooser, Grid, Table, TableColumnResizing, TableColumnVisibility, TableEditColumn, TableEditRow, TableFixedColumns, TableHeaderRow, Toolbar, SearchPanel, TableGroupRow, GroupingPanel, DragDropProvider,} from '#devexpress/dx-react-grid-material-ui';
class UserInformation extends Component {
constructor(props) {
super(props);
this.state = {
isLoaded: true,
columns: [
{name: 'name', title: 'Name'},
{name: 'city', title: 'city'}
],
rows : [
{ sex: "Female", name: "Sandra", city: "Las Vegas", car: "Audi A4" },
{ sex: "Male", name: "Paul", city: "Paris", car: "Nissan Altima" },
{ sex: "Male", name: "Mark", city: "Paris", car: "Honda Accord" },
{ sex: "Male", name: "Paul", city: "Paris", car: "Nissan Altima" },
{ sex: "Female", name: "Linda", city: "Austin", car: "Toyota Corolla" }
]
};
this.commitChanges = this.commitChanges.bind(this);
//this.getRowId = this.getRowId.bind(this);
}
}
commitChanges({ added, changed, deleted }) {
let { rows } = this.state;
let changedRows;
if (added) {
console.log("added")
}
if (changed) {
changedRows = rows.map(row => (changed[row.id] ? { ...row, ...changed[row.id] } : row));
console.log("changed");
console.log(rows.map(row => (changed[row.id])))
}
if (deleted) {
console.log("deleted")
}
};
//getRowId(row) {
// console.log(this.state.rows.indexOf(row));
// return this.state.rows.indexOf(row);
//}
render() {
const { isLoaded, drList, rows, columns } = this.state;
if (!isLoaded) {
return <div>Loading...</div>;
} else {
return (
<div className={"animated fadeIn "}>
<Row>
<Paper>
<Grid
rows={rows}
columns={columns}
getRowId={this.getRowId}
>
<EditingState
onCommitChanges={this.commitChanges}
/>
<Table
/*columnExtensions={tableColumnExtensions}*/
/>
<TableHeaderRow />
<TableEditRow />
<TableEditColumn
showAddCommand
showEditCommand
showDeleteCommand
/>
</Grid>
</Paper>
</Row>
</div>
);
}
}
}
export default UserInformation;

Related

Array of object is getting undefined

This is my Cart.jsx
import { createContext, useEffect } from "react"
import Cake from "../About Section/Cake";
const PdtList = createContext();
export default function Cart() {
let list = [
{
id: "52",
name: "Doll cake"
// images: image80
},
{
id: "53",
name: "Mixed Platte cake"
// images: image81
},
{
id: "54",
name: "Pinata cake"
// images: image82
},
{
id: "55",
name: "Bomb cake"
// images: image83
}
];
return (
<>
<main className="align" >
<h1>Thanks for shopping with us</h1>
<PdtList.Provider value={list}>
<Cake />
</PdtList.Provider>
</main>
</>
)
}
export { PdtList };
This is the Cake.jsx
import { PdtList } from "../Cart/Cart";
import { useContext, useState, useEffect } from "react";
export default function Cake(props) {
const { name, images, bold, cut } = props;
const list = useContext(PdtList);
console.log(list);
console.log(typeof(list));
const Add_Products = (index) => {
console.log('Add_Products called');
let tobeAdded = { name, images, bold };
};
return (
<>
<main className="align unique">
<img src={images} alt="" />
<h1>{name}</h1>
<div className="align2">
<small>Rs {bold}</small>
<small style={{ margin: "0px 10px" }}></small>
<small
style={{ "fontSize": "15px", textDecoration: "line-through" }}
>
Rs {cut}
</small>
</div>
<button onClick={Add_Products} style={{ margin: "10px 0px" }}>
Click here
</button>
</main>
</>
);
}
This is the console,
When I am trying to console the list in the Add_Products function in the Cake.jsx then I am getting undefined.
This is a working codesandbox Link
This is the Birthday.jsx
import image60 from './assets/cake60.jpeg'
import image61 from './assets/cake61.jpeg'
import image62 from './assets/cake62.jpeg'
import image63 from './assets/cake63.jpeg'
import image64 from './assets/cake64.jpeg'
import image65 from './assets/cake65.jpeg'
import image66 from './assets/cake66.jpeg'
import image67 from './assets/cake67.jpeg'
import image68 from './assets/cake68.jpeg'
import image69 from './assets/cake69.jpeg'
import Cake from './Cake'
import { useContext } from "react"
import { PdtList } from "../Cart/Cart"
const pdtArray = [{
id: '32',
name: "Anniversary cake",
images: image60
},
{
id: '33',
name: "Anniversary cake",
images: image61
},
{
id: '134',
name: "Anniversary cake",
images: image62
},
{
id: '34',
name: "Anniversary cake",
images: image63
},
{
id: '35',
name: "Anniversary cake",
images: image64
},
{
id: '36',
name: "Anniversary cake",
images: image65
},
{
id: '37',
name: "Anniversary cake",
images: image66
},
{
id: '38',
name: "Anniversary cake",
images: image67
},
{
id: '39',
name: "Anniversary cake",
images: image68
},
{
id: '40',
name: "Anniversary cake",
images: image69
},]
export default function Birthday(props) {
const list = useContext(PdtList);
console.log(list);
const { title } = props;
return (
<>
<main className='PDT_heading align' >
<h1>{title}</h1>
<div className="grid_system">
{
pdtArray.map((e) => {
const { name, images, id } = e;
return (
<Cake key={id} name={name} images={images} cut="232" bold="343" />
)
})
}
</div>
</main>
</>
)
}
When you are going to use the useContext in a component, make sure that component is wrapped inside the Context.Provider (either the component or the parent of the component). Only then the useContext can able to access the values of the context else it will return the default value which is undefined.
So, the root component will be something lie:
<StrictMode>
<PdtList.Provider value={list}>
<Cart />
<Birthday />
</PdtList.Provider>
</StrictMode>
I wrapped the components inside the Provider so all the components inside can able to access the value.
working link: link

Apex chart doesn't display immediately

I have the following code for a apex chart to be displayed based on value
import React, { Component, Fragment,useState } from "react";
import RestAPI from "services/api";
import axios from "axios";
import Select from 'react-select';
import "d3-transition";
import "tippy.js/dist/tippy.css";
import "tippy.js/animations/scale.css";
/* Chart code */
// Themes begin
// Themes end
import {
Button,
Label,
FormGroup,
Form,
} from "reactstrap";
import ReactApexChart from "react-apexcharts";
import Loader from "react-loader-spinner";
class BarChart extends Component {
constructor(props){
super(props);
this.selectValue=this.selectValue.bind(this)
this.state = {
selectValue:"",
items:[],
weights:[],
isLoaded:true,
showViz:false,
series: [],
options: "",
};
}
selectValue (e) {
var selectValue=this.state.selectValue;
selectValue=e.value;
fetch("http://127.0.0.1:8000/api/values/"+selectValue)
.then(response => response.json())
.then(json => {
this.state.series=[]
var {items,weights}=this.state;
this.setState({
isLoaded:true,
items:json.keywords,
weights:json.weights,
series: [{ name: "Keywords", data: weights }],
options:{
chart: {
type: 'bar',
},
title:{
text:"Top 10 values"
},
plotOptions: {
bar: {
horizontal: true,
}
},
xaxis:{
categories: items
},
grid: {
xaxis: {
show:false,
lines: {
show: false
},
axisTicks:{
show:false,
offsetX: 0,
offsetY: 0
},
axisBorder:{
show:false
}
}
},
yaxis: {
reversed: false,
axisTicks: {
show: false
}
}
},
})
});
this.state.showViz=true;
}
render() {
var {selectValue,items,weights,isLoaded,options,series,showViz}=this.state;
const yeardata = [
{
value: "1",
label: "1"
},
{
value: "2",
label: "2"
},
{
value: "3",
label: "3"
},
{
value: "4",
label: "4"
},
{
value: "5",
label: "5"
},
{
value: "6",
label: "6"
},
{
value: "7",
label: "7"
},
{
value: "8",
label: "8"
},
{
value: "9",
label: "9"
},
{
value: "10",
label: "10"
}
];
//var{items,arr_keys,arr_vals}=this.state;
if(isLoaded){
return (
<>
{ console.log("the values are:",items)}
{ console.log("the values are:",weights)}
{ console.log("the values are:",options)}
{ console.log("the values are:",series)}
<Form role="form" >
<FormGroup>
<h2>Top 10 values</h2>
<Label>Select an Value</Label>
<Select placeholder="Select Option" options={yeardata} value={yeardata.find(obj => obj.value === selectValue)}
onChange={this.selectValue}
/>
<br></br>
{this.state.showViz?(
<ReactApexChart options={this.state.options} series={this.state.series} type="bar" height={250} />):
(<Loader type="Puff">
</Loader>)}
</FormGroup>
</Form>
</>
);
}
else{
return(
<>
</>
)
}
}
}
export default BarChart;
I want to display the chart when I select a value,but it is not displaying.Instead if I select another value,the previous value is displayed.Also,initially a blank plot is rendered which I don't want.Also,the loader is displayed as soon as the page is loaded which I want to avoid too.How could I resolve this?
Screenshot of rendered image:
You never set isLoaded false, so it's always true. You need to set isLoaded to false in constructor and after you receive response - true:
React state is async, you can't set a value just like this this.state.showViz=true; , you need to use this.setState each time you want to change your state and don't forget to put all other state data
this.setState({...this.state, showViz: true});
And as I've understood your logic correctly you need to put this code inside last .then:
this.setState({
isLoaded:true,
items:json.keywords,
weights:json.weights,
showViz: true,
...
You never set selectValue, so you don't need this code var selectValue=this.state.selectValue
Final code:
import React, { Component, Fragment, useState } from "react";
import RestAPI from "services/api";
import axios from "axios";
import Select from "react-select";
import "d3-transition";
import "tippy.js/dist/tippy.css";
import "tippy.js/animations/scale.css";
/* Chart code */
// Themes begin
// Themes end
import { Button, Label, FormGroup, Form } from "reactstrap";
import ReactApexChart from "react-apexcharts";
import Loader from "react-loader-spinner";
class BarChart extends Component {
constructor(props) {
super(props);
this.selectValue = this.selectValue.bind(this);
this.state = {
selectValue: "",
items: [],
weights: [],
isLoaded: true,
showViz: false,
series: [],
options: "",
};
}
selectValue(e) {
var selectValue = this.state.selectValue;
selectValue = e.value;
fetch("http://127.0.0.1:8000/api/values/" + selectValue)
.then((response) => response.json())
.then((json) => {
var { items, weights } = this.state;
this.setState({
isLoaded: true,
items: json.keywords,
weights: json.weights,
showViz: true,
series: [
{
name: "Keywords",
data: weights,
},
],
options: {
chart: {
type: "bar",
},
title: {
text: "Top 10 values",
},
plotOptions: {
bar: {
horizontal: true,
},
},
xaxis: {
categories: items,
},
grid: {
xaxis: {
show: false,
lines: {
show: false,
},
axisTicks: {
show: false,
offsetX: 0,
offsetY: 0,
},
axisBorder: {
show: false,
},
},
},
yaxis: {
reversed: false,
axisTicks: {
show: false,
},
},
},
});
});
}
render() {
var {
selectValue,
items,
weights,
isLoaded,
options,
series,
showViz,
} = this.state;
const yeardata = [
{
value: "1",
label: "1",
},
{
value: "2",
label: "2",
},
{
value: "3",
label: "3",
},
{
value: "4",
label: "4",
},
{
value: "5",
label: "5",
},
{
value: "6",
label: "6",
},
{
value: "7",
label: "7",
},
{
value: "8",
label: "8",
},
{
value: "9",
label: "9",
},
{
value: "10",
label: "10",
},
];
if (isLoaded) {
return (
<>
{console.log("the values are:", items)}
{console.log("the values are:", weights)}
{console.log("the values are:", options)}
{console.log("the values are:", series)}
<Form role="form">
<FormGroup>
<h2> Top 10 values </h2> <Label> Select an Value </Label>
<Select
placeholder="Select Option"
options={yeardata}
value={yeardata.find((obj) => obj.value === selectValue)}
onChange={this.selectValue}
/>
</br>
{this.state.showViz ? (
<ReactApexChart
options={this.state.options}
series={this.state.series}
type="bar"
height={250}
/>
) : (
<Loader type="Puff"></Loader>
)}
</FormGroup>
</Form>
</>
);
} else {
return <></>;
}
}
}

Ant Design for React : Show/Hide particular column

I need a bit of help here, In an Ant Design table, I need to hide/show a particular column of a table depending on a state value. In the given sandbox link, I need to hide the surname column whenever the switch is Off and show when the switch is On.
Please, someone, look into this, and help me out.
Reference: https://codesandbox.io/s/purple-sun-1rtz1?file=/index.js
There is a working code, but it should be more customize, interactivize, and refactorize depending on your need:
// You can also modify the data in the `handleChnage`
// Or conditionally display it like here:
class EditableTable extends React.Component {
state = {
surNameShow: false
};
constructor(props) {
super(props);
this.columns = [
{
title: "Name",
dataIndex: "name",
width: "30%"
},
{
title: "Surname",
dataIndex: "surname",
width: "30%"
}
];
this.state = {
dataSource: [
{
key: "0",
name: "Edward 1",
surname: "King 1"
},
{
key: "1",
name: "Edward 2",
surname: "King 2"
}
]
};
}
handleChnage = key => {
this.setState({ surNameShow: !this.state.surNameShow }, () => {
console.log(this.state.surNameShow);
});
};
render() {
const { dataSource } = this.state;
const columns = this.columns;
return (
<div>
<p className="mr-3"> Show surname</p>
<Switch onChange={() => this.handleChnage()} />
<Table
bordered
dataSource={dataSource}
columns={
this.state.surNameShow
? columns
: columns.filter(ea => ea.dataIndex !== "surname")
}
pagination={false}
/>
</div>
);
}
}
ReactDOM.render(<EditableTable />, document.getElementById("container"));

How to add SrNo (#) column at first position at mui-datatable React.js

Created table using React and MUI-Datatables: need to add SrNo column at first, also need to add Delete and IsActive button.
import React, { useState, useEffect } from 'react';
import Grid from '#material-ui/core/Grid';
import Switch from '#material-ui/core/Switch';
import MUIDataTable from "mui-datatables";
export const Services = () => {
const [itemList, setItemList] = useState([]);
const [mainColumns, setMainColumns] = useState([]);
const selectData = async () => {
const response = await ServiceAPI(); // data from web wervice
var data = JSON.parse(response.data);
setItemList(data);
};
const createColumns = () => {
var columns = [];
// how to add Sr No column
columns.push(
{
label: 'ID',
name: 'service_id',
});
columns.push(
{
label: 'Name',
name: 'service_name',
});
setMainColumns(columns);
};
useEffect(() => {
createColumns();
selectData();
}, []);
return (
<>
<h3>Service</h3>
<Grid container >
<Grid item xs={12}>
<MUIDataTable
title={"Service"}
data={itemList}
columns={mainColumns}
className="table nowrap"
/>
</Grid>
</Grid>
</>
);
}
tried below code for active/deactivate, but OnChange() is run every time, which should call on only click event (also tried OnClick()):
columns.push(
{
label: 'Active',
name: 'is_active',
options: {
filter: false,
sort: false,
customBodyRender: (value, tableMeta, updateValue) => {
const serviceID = tableMeta.rowData[0];
return (
<Switch color="primary" checked={value} value={value} onChange={activate}/>
/>
);
}
}
});
Please check example. I have added serial number and delete button in this example.
import React from "react";
import ReactDOM from "react-dom";
import MUIDataTable from "mui-datatables";
import IconButton from "#material-ui/core/IconButton";
import Button from "#material-ui/core/Button";
export default class MuiDatatableSerial extends React.Component {
render() {
const columns = [
{name: "sl", label: "Serial No"},
{name: "name", label: "Name"},
{name: "title", label: "Title"},
{name: "location", label: "Location"},
{name: "age", label: "Age"},
{name: "salary", label: "Salary"},
{
name: "delete",
label: "",
options: {
filter: false,
sort: false,
customBodyRender: (value, tableMeta, updateValue) => {
return <Button
color="secondary"
onClick={(ev) =>
alert('deleted')
}> Delete
</Button>;
},
}
}
];
const data = [
{name: "Khabir Uddin", title: "Senior Software Engineer", location: "Dhaka", age: 38, salary: "$150,000"},
{name: "Gabby George", title: "Business Analyst", location: "Minneapolis", age: 30, salary: "$100,000"},
{name: "Aiden Lloyd", title: "Business Consultant", location: "Dallas", age: 55, salary: "$200,000"}
];
let newData = [];
data.map((item, index) => {
newData.push({sl: index + 1, ...item});
});
const options = {
selectableRows: "none",
onRowsSelect: (rowsSelected, allRows) => {
},
};
return (
<MUIDataTable
title={"ACME Employee list"}
data={newData}
columns={columns}
options={options}
/>
);
}
}

Autosuggest/Combobox suggestion wont display

For some reason the suggestion wont display, there are no error messages in console.
Senario
User clicks on combobox, suggestion are displayed. (Working)
User selects a suggestion. Suggestion is displayed in combobox.
(Selection its loading in a single span)
If user clicks on combobox after making a selection, combobox will clear value, but previous selection will display as a highlighted first choice. Also updated suggestion display below first choice.
( I really need help on this one, I can see the data in the console log. But since the suggestions are not displaying I can tell if its displays as requested )
(see image for reference)
react-autosuggest react-autosuggest#9.3.4
Component Code
import React, { Component } from "react";
import ReactDOM, { findDOMNode } from "react-dom";
import PropTypes from "prop-types";
import classNames from "classnames";
import Autosuggest from "react-autosuggest";
import Icon from '../Components/Icons/Icons';
class Autocomplete extends Component {
constructor() {
super();
this.state = {
value: "",
suggestions: [],
isTouched: false,
multi: false,
selectedInput: ""
};
this.onChange = this.onChange.bind(this);
this.onClick = this.onClick.bind(this);
this.blurCallback = this.blurCallback.bind(this);
this.triggerFocus = this.triggerFocus.bind(this);
this.handleClear = this.handleClear.bind(this);
}
getSuggestionValue = suggestion => suggestion.text;
renderSuggestion = suggestion => (<span>{suggestion.text}</span>)
escapeRegexCharacters = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
getSectionSuggestions = section => section && section.items;
getSuggestions = (value, selected, reason) => {
let suggestions = this.props.data;
if (value !== undefined) {
const escapedValue = this.escapeRegexCharacters(value.trim());
const selectedInput = [];
selectedInput.push(selected);
const regex = new RegExp(escapedValue, "i");
const filtered = suggestions.filter(language =>
regex.test(language.text)
);
if (escapedValue === "") {
return {
suggestions: [
{ text: selectedInput[0], items: [] },
{ text: "", items: filtered }
],
multi: true
};
}
if (!filtered.length) {
return {
suggestions: selectedInput.length > 0 ? selectedInput : filtered,
multi: false
};
}
return {
suggestions: [{
text: selectedInput[0],
items: selectedInput.length > 0 ? selectedInput : filtered
},
{
text: "",
items: reason === "focused" ? suggestions : filtered
}],
multi: true
};
} else return;
};
onSuggestionsFetchRequested = ({ value, reason }) => {
if (reason === "input-focused") {
this.setState({ value: "" });
const { multi, suggestions } = this.getSuggestions(
value,
this.state.selectedInput ? this.state.selectedInput : "",
"focused"
);
this.setState({
suggestions,
multi
});
} else {
const { multi, suggestions } = this.getSuggestions(
value,
this.state.selectedInput ? this.state.selectedInput : "",
"notfocused"
);
this.setState({
suggestions,
multi
});
}
};
onSuggestionsClearRequested = () => {
this.setState({
suggestions: [],
multi: false
});
};
onChange = (event, { newValue, method }) => {
if (method === "enter") {
this.setState({
value: this.state.value
});
} else {
this.setState({
value: newValue
});
}
if(this.props.search) {
this.props.search(newValue, ReactDOM.findDOMNode(this).parentNode.parentNode.querySelectorAll('li'));
};
};
onSuggestionSelected = (ev,
{ suggestion, suggestionValue, suggestionIndex, sectionIndex, method }
) => {
this.setState({
selectedInput: suggestionValue
});
};
blurCallback (ev) {
this.setState({ isTouched: false });
}
handleClear() {
this.setState({
value: ''
})
}
onClick(ev) {
this.setState({ isTouched: true });
}
triggerFocus() {
const input = document.getElementById(this.props.id);
input.focus();
}
render() {
const theme = {
container: "el-form",
containerOpen: "react-autosuggest__container--open",
input: "autocomplete form-control",
inputOpen: "react-autosuggest__input--open",
inputFocused: "react-autosuggest__input--focused",
suggestionsContainer: "react-autosuggest__suggestions-container",
suggestionsContainerOpen:
"react-autosuggest__suggestions-container--open",
suggestionsList: "autocomplete-wrap",
suggestion: "react-autosuggest__suggestion",
suggestionFirst: "react-autosuggest__suggestion--first",
suggestionHighlighted: "react-autosuggest__suggestion--highlighted",
sectionContainer: "react-autosuggest__section-container",
sectionContainerFirst: "react-autosuggest__section-container--first",
sectionTitle: "react-autosuggest__section-title"
};
const {
className,
placeholder,
data,
disabled,
label,
labelClass,
icon,
iconSize,
iconClass,
clear,
clearClass,
id,
search,
...attributes
} = this.props;
const labelClassFix = classNames(
isNotEmpty && "active",
disabled && "disabled",
labelClass
);
const iconClassFix = classNames(
"prefix",
this.state.isTouched && "active",
iconClass
);
const clearClassFix = classNames(
clearClass
)
const isclearVisible = () => {
let hiddenOrNot = "hidden"
if (this.state.value) {
hiddenOrNot = "visible";
}
return hiddenOrNot;
}
const clearStyleFix = {
position: "absolute",
zIndex: 2,
top: "2.5rem",
right: "10px",
border: "none",
background: "0 0",
visibility: isclearVisible(),
}
let isNotEmpty =
Boolean(this.state.value) || placeholder || this.state.isTouched;
const { value, suggestions, multi } = this.state;
const inputProps = {
placeholder: placeholder,
value,
onChange: this.onChange,
onBlur: this.blurCallback,
onClick: this.onClick,
onFocus: this.onFocus,
id: this.props.id,
name: this.props.name
};
const renderInputComponent = inputProps => (
<div>
{ icon && <Icon icon={icon} className={iconClassFix}/> }
<input
type="text"
id={id}
name={name}
className="form-control"
{...inputProps}
onFocus={(ev, val) => {
this.onClick();
inputProps.onFocus(ev, val);
}}
/>
<label
htmlFor={id}
id={`label for ${id}`}
onClick={this.triggerFocus}
className={labelClassFix}
>
{ label }
</label>
{ clear &&
<Icon icon="close" onClick={this.handleClear} style={clearStyleFix}
className={clearClassFix}/>
}
</div>
);
return (
<Autosuggest
multiSection={multi}
renderSectionTitle={this.renderSuggestion}
getSectionSuggestions={this.getSectionSuggestions}
suggestions={suggestions}
highlightFirstSuggestion={true}
focusInputOnSuggestionClick={false}
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
getSuggestionValue={this.getSuggestionValue}
renderSuggestion={this.renderSuggestion}
inputProps={inputProps}
theme={theme}
renderInputComponent={renderInputComponent}
shouldRenderSuggestions={ () => true }
onSuggestionSelected={this.onSuggestionSelected}
/>
);
}
}
Autocomplete.propTypes = {
className: PropTypes.string,
icon: PropTypes.string,
id: PropTypes.string,
name: PropTypes.string,
};
Autocomplete.defaultProps = {
id: 'autocomplete-1',
name: '',
clear: true
};
export default Autocomplete;
In use Component
const states = [ "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illnois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" ];
<Autocomplete
data={states}
label="Choose your state"
icon="lightbulb"
clear
clearClass="grey-text" id="combobox-states" name="state-selection"
className="mx-auto"
/>
Codesandbox
you need a return in some of your callbacks :
getSuggestionValue = suggestion => {
return suggestion;
}
getSectionSuggestions = (section) => {
return section && section.items;
}
Edit
In getSuggestions you need to return an array directly, not an object.
see https://codesandbox.io/s/w04jpzjr4k

Resources