I have some components that are rendering another component (FetchNextPageButton) that is already tested in isolation, like these ones: The thing is that I’d not like having to add tests on each of these components for a functionality that is already tested somewhere else, so I think that should be enough just to test that the component is rendered and
Tag: reactjs
value of using React.forwardRef vs custom ref prop
I see that React.forwardRef seems to be the sanctioned way of passing a ref to a child functional component, from the react docs: However, what is the advantage of doing this over simply passing a custom prop?: The only advantage I can think of is maybe having a consistent api for refs, but is there any other advantage? Does passing
How do I turn on the webview autocomplete for an login form in Ionic’s capacitor in iOS?
I want to know how to enable the autocomplete for a login form in Capacitor (or if it’s possible). I’m using Ionic React. It works if access the page in Safari on iOS and even if you pin it to the home screen. But if you bundle the web app in Capacitor, the autocomplete is not there. Here’s the code
Is there a non-hook alternative for the React Material-UI makeStyles() function that works for class Components
Im using the makeStyles() function in material-UI’s react library, and am getting the following error Hooks can only be called inside the body of a function component. Below is an example of the kind of code I am using. I know the error is being thrown because I’m trying to use makeStyles() in my class component (As shown above). However,
What is the difference between the different ways of importing material-ui components?
From reading the material-ui documentation and online examples, there seem to be different ways of importing the same item: What is the difference between the different way of doing an import? Answer The main difference occurs when bundling. Using the named import: pulls in the entire @material-ui/core module. That means you bundle everything in the module (and all of the
How can i persist data in react native application?
I want to create a React Native app that persists local data and then syncs to the server. Please help me to find a way for this. Answer React Native provides methods to persist data. Some are provided out of the box while others are libraries you have to install and use. Below are popular methods of persisting data in
How to reset ant design table selected rows?
I am using ant design table component and I have selected rows. I want onClick reset selected rows. I can not find out where it stores selected rows. Any Idea how to clear selected rows? Answer rowSelection also takes selectedRowKeys property that will help you control the selected rows at any point in time. Codesandbox Example | Antd Docs
Redux deep clone – state is always equal
I have the following reducer in React Redux: And this is my object: The reducer as such seems to work, it toggles the values correctly. But: Redux always shows “states are equal”, which is bad as it won’t recognize changes. Can someone help ? I assume that I am returning a new object.. Answer Although you take a copy of
setState only setting last input when using object as state
Im trying to create a form with React. This form uses a custom Input component I created various times. In the parent form Im trying to get a complete object with all names and all values of the form: For this, I created a ‘component updated’ hook, that calls the function property onNewValue to send the new value to the
Dynamic media query with React Hooks
i’m trying to build a Bootstrap Grid(with Container, Row, col-md-12, etc) from ground on React. My first problem is with Container. In Bootstrap, Container has multiple media queries. I could(i’m using Styled Components with Styled Tools) obviously create multiple media queries that will overwrite each other but i know this is not the best way. I was thinking on creating