Comments (4)
So I used,
EuiErrorBoundary
as well but it couldn't catch the error.
EuiErrorBoundary
catches errors thrown by JS code due to developer implementation or API issues - it does not catch errors due to user input. Basically, if an error message doesn't appear in your devtools console, EuiErrorBoundary
won't catch it.
Can you suggest some usage or work around to catch the error from
EuiSearchBar
or in its filters.
Your required onChange
callback passes back any errors in the error
key. If you really want to use EuiErrorBoundary
for this, simply throw any caught errors, for example:
const searchBarOnChange = ({ query, queryText, error }) => {
if (error) throw new Error(error);
// Do something with the query
};
<EuiSearchBar onChange={searchBarOnChange}) />
from eui.
Thanks @cee-chen , but i have already raising the error when there is a change in the SearchBar input, const onChange = ({ query, error }) => { throw new Error("this will cause searchbar error")
https://github.com/Harshav0423/nextjs-eui/blob/main/src/app/components/search.jsx
from eui.
Ah, sorry, you're right. Throwing an error from the onChange
won't trigger EuiErrorBoundary
, what you need to do is store the error
in state and then add a useEffect
that throws on error
change. This will cause a rerender and EuiErrorBoundary
to correctly update.
Example:
const [error, setError] = useState();
const searchBarOnChange = ({ query, queryText, error }) => {
if (error) setError(error);
// otherwise do something with the query
};
useEffect(() => {
if (error) throw new Error(error.message);
}, [error]);
return (
<EuiErrorBoundary>
<EuiSearchBar onChange={searchBarOnChange} />
</EuiErrorBoundary>
);
from eui.
Thanks for that, I used react-error-boundary
to catch any rendering errors. Replaced the EuiSearchbar
to EuiBasicTable
and wrapped ErrorBoundary
around that, so that when there is an error in rendering the table it is going to catch that.
from eui.
Related Issues (20)
- [EuiIcon] Icon asset paths/content off center from viewbox HOT 8
- [EuiSuperDatePicker] Allow setting absolute dates without Enter key HOT 1
- [New docs] Implement basic design changes to match the custom theme
- [EuiTooltip][KEYBOARD]: Would we consider adding `ESC` keypress to dismiss the tooltip?
- [EuiRange] Ticks not displaying correctly in React Strict Mode HOT 2
- [EuiSelectable] Screen reader arrow navigation experience is broken on Safari+VO HOT 1
- [Meta] [New docs] Full-text search
- [Meta] [New docs] Publish Elastic Design System patterns
- [EuiInputPopover] Removed setTimeout causes flaky test behavior HOT 1
- [EuiDualRange] Upper value isn't allowed to be blank HOT 3
- [EuiPageTemplate] Account for new serverless header style HOT 5
- [EuiDataGrid] Grid grows to infinite height in flex container if `height` not provided
- [EuiFlex] Add missing props to `EuiFlexGroup` and `EuiFlexItem`
- [Meta] Support React Strict Mode
- EuiPortal should be able to use different portal target than document.body based on provided Context HOT 7
- [EuiDataGrid] Cell text content visible below truncation when using `fontSize: "s"`
- FlexItem does not accept HTMLAttributes like title anymore
- EuiSteps unordered variant HOT 1
- [EuiSelectableTemplateSitewide] Allow default a link behavior for results
- [EuiTabs ][A11Y] - Using `EuiBetaBadge` within `EuiTab`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eui.