'How do I export and use a function defined with this type of component?
So, I have a file called UserPaginatedDataTable.js which looks like this:
https://pastecord.com/icagatowul.js
It contains a function called searchHandler here:
const searchHandler = () => {
setClearFilters(false);
memoDataHandler();
};
I'd like to import that function (and whatever dependencies it requires) over to a different file called TableFilters.js.
import UserPaginatedDataTable from "../UserPaginatedDataTable";
.
.
.
export const InputColumnFilter = ({ column }) => {
const { filterValue, setFilter } = column;
return (
<span>
<input value={filterValue || ""} onChange={(e) => {
setFilter(e.target.value);
if (e.charCode === 13) {
searchHandler() // where I plan to call the function
}
} } className="table-col-filter"
/>
</span>
);
};
However, I'm getting a 'searchHandler' is not defined. and 'UserPaginatedDataTable' is defined but never used. message. Even only trying to import searchHandler by itself results in a parsing error because of an unexpected token: https://pastecord.com/madubilova.js (TableFilters.js)
Am I doing imports for this kind of component wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
