Autosuggest/Combobox suggestion wont display - reactjs

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

Related

React select not updating correctly after updating the another related select field

Here is my code:
https://codesandbox.io/s/inspiring-rhodes-jwv1zd?file=/src/App.js
To reproduce the issue:
Select Fruits from first select field.
Next, select one of the fruits from second field.
Next, again change the first field value from fruits to Vegetable, when I changed it to vegetables, the options on second field will be updated to vegetable lists, but still it keeps showing previous fruits as the selected one. How could I fix it? I want the first options from vegetables to be selected.
I have checked your code and made updates to the file.
First, there should be ref prop in the AppCreatableSelect.jsx Component.
This is updated AppCreatableSelect.jsx Component code.
import React, { forwardRef } from "react";
import { Controller } from "react-hook-form";
import ReactSelect from "react-select";
const AppCreatableSelect = forwardRef(
(
{
control,
options,
fieldName,
defaultValue,
errors,
className,
selectClassList,
isSearchable = true,
isClearable = true
},
ref
) => {
return (
<>
<Controller
name={fieldName}
className={`form-control ${className} ${
errors[fieldName] ? "is-invalid" : ""
}`}
control={control}
defaultValue={
options.length && options.find((row) => row.value === defaultValue)
}
selected={true}
render={({ field: { onChange, onBlur, name } }) => (
<ReactSelect
ref={ref}
isClearable={isClearable}
onBlur={onBlur} // notify when input is touched
inputRef={ref}
defaultValue={
options.length &&
options.find((row) => row.value.value === defaultValue)
}
onChange={onChange}
options={options}
className={selectClassList}
isSearchable={isSearchable}
/>
)}
/>
</>
);
}
);
export default AppCreatableSelect;
Here is the updated App.js Component code.
import "./styles.css";
import AppCreatableSelect from "./component/AppCreatableSelect";
import { useForm } from "react-hook-form";
import { useEffect, useState, useRef } from "react";
export default function App() {
const [types, setTypes] = useState([]);
const [items, setItems] = useState([]);
const [colors, setColors] = useState([]);
const itemsRef = useRef();
const colorsRef = useRef();
const {
control,
watch,
formState: { errors }
} = useForm();
const watchType = watch("types");
const watchItems = watch("items");
useEffect(() => {
setTimeout(() => {
setTypes([
{ label: "Fruits", value: "fruits" },
{ label: "Vegetables", value: "vegetables" }
]);
});
}, []);
useEffect(() => {
if (watchType) {
if (watchType.value === "fruits") {
setItems([
{ label: "Apple", value: "apple" },
{ label: "Orange", value: "orange" }
]);
itemsRef.current.setValue({ label: "Apple", value: "apple" });
}
if (watchType.value === "vegetables") {
setItems([
{ label: "Cabbage", value: "cabbage" },
{ label: "Cauliflower", value: "cauliflower" }
]);
itemsRef.current.setValue({ label: "Cabbage", value: "cabbage" });
}
}
}, [watchType]);
useEffect(() => {
if (watchItems) {
if (watchItems.value === "apple") {
setColors([
{ label: "Red Apple", value: "redApple" },
{ label: "Green Apple", value: "greenApple" }
]);
colorsRef.current.setValue({ label: "Red Apple", value: "redApple" });
}
if (watchItems.value === "orange") {
setColors([
{ label: "Red Orange", value: "redOrange" },
{ label: "Green Orange", value: "greenOrange" }
]);
colorsRef.current.setValue({ label: "Red Orange", value: "redOrange" });
}
if (watchItems.value === "cabbage") {
setColors([
{ label: "Red Cabbage", value: "redCabbage" },
{ label: "Green Cabbage", value: "greenCabbage" }
]);
colorsRef.current.setValue({
label: "Red Cabbage",
value: "redCabbage"
});
}
if (watchItems.value === "cauliflower") {
setColors([
{ label: "Red Cauliflower", value: "redCauliflower" },
{ label: "Green Cauliflower", value: "greenCauliflower" }
]);
colorsRef.current.setValue({
label: "Red Cauliflower",
value: "redCauliflower"
});
}
}
}, [watchItems]);
return (
<div className="App">
<AppCreatableSelect
control={control}
options={types}
fieldName="types"
errors={errors}
isClearable={false}
defaultValue={types[0]}
/>
<AppCreatableSelect
ref={itemsRef}
control={control}
options={items}
fieldName="items"
errors={errors}
isClearable={false}
defaultValue={items[0]}
/>
<AppCreatableSelect
ref={colorsRef}
control={control}
options={colors}
fieldName="itemColor"
errors={errors}
isClearable={false}
/>
</div>
);
}

React Data Grid: Custom DropDown Editor: value is not getting updated. Grid is not getting enabled for editing

on react-data-grid 7.0.0-beta
I read through the most recent demos provided in git repo for react-data-grid and implemented a custom dropdown for my use case.
Dropdown seems to be working but it is not updating the grid data upon selection. The editable property doesn't seem to be working either.
test code is implemented here:
Sandbox: https://codesandbox.io/s/react-data-grid-custom-dropdown-editor-kcy5n
export const EntryCriteriaGrid = () => {
const columns = [
{
key: "r1",
name: "Criteria",
width: "50%",
resizable: true,
editable: true
},
{
key: "status",
name: "Status",
editor: DropdownCustomEditor,
editorOptions: {
editOnClick: true
},
editable: true
},
{ key: "tracker", name: "Tracker", editable: true }
];
const rows = [
{ r1: "data 1", status: "BLOCKED", tracker: "tracker 1" },
{ r1: "data 2", status: "PASS", tracker: "tracker 1" },
{ r1: "data 3", status: "ISSUE", tracker: "tracker 2" }
];
const [state, setState] = useState({ rows });
const onGridRowsUpdated = ({ fromRow, toRow, updated }) => {
setState((state) => {
const rows = state.rows.slice();
for (let i = fromRow; i <= toRow; i++) {
rows[i] = { ...rows[i], ...updated };
}
return { rows };
});
};
return (
<div>
<ReactDataGrid
columns={columns}
rows={state.rows}
rowsCount={3}
onGridRowsUpdated={onGridRowsUpdated}
enableCellSelect={true}
className="rdg-light"
/>
</div>
);
};
export default EntryCriteriaGrid;
import React, { Component } from "react";
import ReactDOM from "react-dom";
export default class DropdownCustomEditor extends Component {
constructor(props) {
super(props);
this.state = {
selected: ""
};
this.options = [
{ id: "blocked", value: "BLOCKED" },
{ id: "pass", value: "PASS" },
{ id: "issue", value: "ISSUE" },
{ id: "notStarted", value: "NOT STARTED" }
];
}
componentDidMount() {
if (this.props.row && this.props.row.status)
this.setState({ selected: this.props.row.status });
}
getValue = function () {
return { status: this.state.selected };
};
getInputNode() {
return ReactDOM.findDOMNode(this).getElementsByTagName("select")[0];
}
update(e) {
this.setState({ selected: e.target.value });
this.props.onRowChange({ ...this.props.row, status: e.target.value }, true);
}
render() {
return (
<select
className="rdg-select-editor"
onChange={(e) => this.update(e)}
autoFocus
value={this.state.selected}
>
{this.options.map((elem) => {
return (
<option key={elem.id} value={elem.value}>
{elem.value}
</option>
);
})}
</select>
);
}
}
Just change your code as follows:
In DropdownCustomEditor component:
update(e) {
this.setState({ selected: e.target.value });
this.props.onRowChange({ ...this.props.row, status: e.target.value });
}
In EntryCriteriaGrid component
const onGridRowsUpdated = (rows) => {
setState({ rows });
};
and
<ReactDataGrid
columns={columns}
rows={state.rows}
rowsCount={3}
//onRowsUpdate={onGridRowsUpdated}
enableCellSelect={true}
className="rdg-light"
onRowsChange={(rows) => onGridRowsUpdated(rows)}
/>

Filtering an array of products

I'm a newbie and I try to set up a search engine that will render the products, base on the value I type on the input.
With my code below, I tried that way but it seems that my logic isn't correct.
Could someone go through my code and check it out and can give me some insight afterward, please.
Thank you in advance.
import data from "./utils/data";
const App = () => {
const [searchValue, setSearchValue] = useState("");
const handleChange = (e) => {
setSearchValue(e.target.value);
};
return (
<div>
<SearchInput handleChange={handleChange} searchValue={searchValue} />
<Products data={data} searchValue={searchValue} />
</div>
);
};
const SearchInput = ({ searchValue, handleChange }) => {
return (
<div>
<input
type="text"
placeholder="Search specific item..."
value={searchValue}
onChange={handleChange}
/>
</div>
);
};
export default SearchInput;
function Products({ data, searchValue }) {
const [productsInfo, setProductsInfo] = useState([]);
useEffect(() => {
filteredProducts(data);
}, []);
const filteredProducts = (products) => {
if (searchValue.toLowerCase().trim() === "") {
setProductsInfo(products);
} else {
const seekedItem = productsInfo.filter(
(product) =>
product.name.toLowerCase().trim().includes(searchValue) ===
searchValue.toLowerCase().trim()
);
setProductsInfo(seekedItem);
}
};
const productsData =
productsInfo.length <= 0 ? (
<div>Loading...</div>
) : (
<div>
{productsInfo.map((product, index) => {
return (
<div
key={index}
style={{ backgroundColor: "grey", maxWidth: "300px" }}
>
<h4>{product.name}</h4>
<p>{product.category}</p>
<p> {product.price} </p>
<hr />
</div>
);
})}
</div>
);
return productsData;
}
export default Products;
const data = [
{
category: "Sporting Goods",
price: "$49.99",
stocked: true,
name: "Football",
},
{
category: "Sporting Goods",
price: "$9.99",
stocked: true,
name: "Baseball",
},
{
category: "Sporting Goods",
price: "$29.99",
stocked: false,
name: "Basketball",
},
{
category: "Electronics",
price: "$99.99",
stocked: true,
name: "iPod Touch",
},
{
category: "Electronics",
price: "$399.99",
stocked: false,
name: "iPhone 5",
},
{ category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7" },
];
export default data;
If you return empty array in second params in useEffect This function fired only once. Try that:
useEffect(() => {
filteredProducts(data);
}, [searchValue]);
.includes return true or false (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
Try that:
const filteredProducts = (products) => {
if (searchValue.toLowerCase().trim() === "") {
setProductsInfo(products);
} else {
const seekedItem = productsInfo.filter(
(product) =>
product.name.toLowerCase().trim().includes(searchValue)
);
setProductsInfo(seekedItem);
}
};

How to implement AddAdiditions in React Sematic UI using Hooks?

I want to have a drop down in my application which allows the user to add an item to the dropdown. I am using React Sematic UI.
Sematic UI Dropdown ALlowAdditions
I am new to react hooks and I want to know how I can implement the onChange and onAddition function using hooks.
import React, { Component } from 'react'
import { Dropdown } from 'semantic-ui-react'
const options = [
{ key: 'English', text: 'English', value: 'English' },
{ key: 'French', text: 'French', value: 'French' },
{ key: 'Spanish', text: 'Spanish', value: 'Spanish' },
{ key: 'German', text: 'German', value: 'German' },
{ key: 'Chinese', text: 'Chinese', value: 'Chinese' },
]
class DropdownExampleAllowAdditions extends Component {
state = { options }
handleAddition = (e, { value }) => {
this.setState((prevState) => ({
options: [{ text: value, value }, ...prevState.options],
}))
}
handleChange = (e, { value }) => this.setState({ currentValue: value })
render() {
const { currentValue } = this.state
return (
<Dropdown
options={this.state.options}
placeholder='Choose Language'
search
selection
fluid
allowAdditions
value={currentValue}
onAddItem={this.handleAddition}
onChange={this.handleChange}
/>
)
}
}
export default DropdownExampleAllowAdditions
Any help would be greatly appreciated. Thanks in advance :)
import React, { useState } from "react";
import { Dropdown } from "semantic-ui-react";
const options = [
{ key: "English", text: "English", value: "English" },
{ key: "French", text: "French", value: "French" },
{ key: "Spanish", text: "Spanish", value: "Spanish" },
{ key: "German", text: "German", value: "German" },
{ key: "Chinese", text: "Chinese", value: "Chinese" }
];
const DropDownWithHooks = () => {
const [dropDownOptions, setDropDownOptions] = useState(options);
const [currentValue, setCurrentValue] = useState("");
const handleAddition = (e, { value }) => {
setDropDownOptions((prevOptions) => [
{ text: value, value },
...prevOptions
]);
};
const handleChange = (e, { value }) => setCurrentValue(value);
return (
<Dropdown
options={dropDownOptions}
placeholder="Choose Language"
search
selection
fluid
allowAdditions
value={currentValue}
onAddItem={handleAddition}
onChange={handleChange}
/>
);
};
export default DropDownWithHooks;
Working Sandbox

Closing a modal popping up through a react table

I am popping up a modal an edit data through a button-click in the react table.
After performing the function when I try to close the modal, it would navigate to an empty page. I am calling the modal in the parent component from a child component as folllows.
<EditCardModal
show={this.state.show}
onHide={this.closeModal}
title="EDIT CARD"
id={this.state.id}
name={this.state.name}
uid={this.state.uid}
status={this.state.status}
serial={this.state.serial}
nodeType={this.state.nodeType}
onChange={this.handleChange}
handleEdit={this.handleEdit}
msg={this.state.msg}
/>
In the child component a close button is added to the modal header as below.
<Modal.Header closeButton>
<Modal.Title>{this.props.title}</Modal.Title>
</Modal.Header>
The method below shows how I close the modal.
closeModal = async event => {
event.preventDefault();
await this.setState({
show: false
});
};
TableList.js
class TableList extends Component {
constructor(props) {
super(props);
this.state = { show: false };
this.nodeCreationData = {};
this.state = {
show: false,
excelData: null,
rowInfo: null,
name: "",
uid: "",
order: "",
serial: "",
status: "",
excelDataValidation: false,
nodeType: "",
isSuccess: false,
a: null,
msg: "",
title: ""
};
this.showModal = this.showModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
showModal() {
// event.preventDefault();
this.setState({
show: true
});
}
closeModal() {
// event.preventDefault();
debugger;
this.setState({
show: false
});
}
componentWillMount() {
this.props.queryStart();
this.props.getCard();
}
getTdProps = (state, rowInfo, column, instance) => {
return {
onClick: async (e, handleOriginal) => {
console.log("It was in this row:", rowInfo.original.name);
await this.setState({
id: rowInfo.original.id,
name: rowInfo.original.name,
uid: rowInfo.original.uid,
serial: rowInfo.original.serial,
status: rowInfo.original.status,
nodeType: rowInfo.original.nodeType
});
if (handleOriginal) {
handleOriginal();
}
console.log("State", this.state);
}
};
};
tableHeaders = [
{
Header: "ID",
accessor: "id"
},
{
Header: "NAME",
accessor: "name"
},
{
Header: "UID",
accessor: "uid"
},
{
Header: "STATUS",
accessor: "status"
},
{
Header: "SERIAL",
accessor: "serial"
},
{
Header: "UPDATED_AT",
accessor: "updatedAt"
},
{
Header: "NODE TYPE",
accessor: "nodeType"
},
{
Header: "ACTION",
accessor: "action",
minWidth: 150,
Cell: ({ row }) => (
<div>
<Button type="submit" onClick={this.showModal}>
UPDATE CARD
</Button>
</div>
)
}
];
handleEdit = () => {
this.props.editCard({
id: this.state.id,
createdAt: this.state.createdAt,
name: this.state.name,
uid: this.state.uid,
serial: this.state.serial,
name: this.state.name,
status: this.state.status,
nodeType: this.state.nodeType
});
};
handleChange = event => {
if (event.target.name == "id") {
this.setState({
id: event.target.value
});
}
if (event.target.name == "nodeType") {
this.setState({
nodeType: event.target.value
});
}
if (event.target.name == "name") {
this.setState({
name: event.target.value
});
}
if (event.target.name == "serial") {
this.setState({
serail: event.target.value
});
}
if (event.target.name == "uid") {
this.setState({
uid: event.target.value
});
}
if (event.target.name == "status") {
this.setState({
status: event.target.value
});
}
};
render() {
const { TableListData, TableListLoading } = this.props;
var nodeTableList = null;
if (TableListData == null) {
nodeTableList = "No data";
} else {
nodeTableList = (
<ReactTable
// ref={r => {
// this.reactTable = r;
// }}
data={TableListData[0]}
columns={this.tableHeaders}
getTdProps={this.getTdProps}
/>
);
}
let loadingMsg = TableListLoading && <Alert>Loading</Alert>; //Show loading message
return (
<Grid fluid>
<EditCardModal
show={this.state.show}
onHide={this.closeModal}
title="EDIT CARD"
id={this.state.id}
name={this.state.name}
uid={this.state.uid}
status={this.state.status}
serial={this.state.serial}
nodeType={this.state.nodeType}
onChange={this.handleChange}
handleEdit={this.handleEdit}
msg={this.state.msg}
/>
<Row>
<Col xs={12} md={12}>
{loadingMsg}
{nodeTableList}
</Col>
</Row>
</Grid>
);
}
}
function mapStateToProps(state) {
return {
TableListData: state.cardUploader.data
};
}
export default withRouter(
connect(
mapStateToProps,
cardUploaderActions
)(TableList)
);
Can someone help me to solving this matter?

Resources