I am trying to populate a Datatable (PrimeReact) column with a custom data, more specifically an image JSX. Now the source of that image needs to be fetched and validated using multiple fetch calls. My problem here is that since Promises are asynchronous, I am not able to form and return that image tag. I would really appreciate any suggestion on how to achieve this.
Related
i want to send the multiple form details to the single api in react native
one of my friend suggest me to try to make a form object inside the parent component and then pass the form object to the children form and bind it. And then on Submit just post the data which is in the object. but i'm new to this and i'm not getting how to do that if anybody share me the sample code. i mean example how to do that'll be helpful
That should be easy:
var formData = new FormData();
fromData.append('key1','value1');
fromData.append('key2','value2');
I am having a trouble using the Material Table from mbrn. I will try to resume the problem as better as i can. Here it goes an image:
Material Table used
I am using this table component. I am using remote data that comes from an API call. The problem is that on each letter that i type on each column filter, the table updates and call the API for refresh. I don't want that.
What i want is to let the user write the column filters that he wants and then click on the "Atualizar" button and when clicked the call to API with the filters and the refresh happens.
Anyone can help me to do it?
Try following, useEffect() with no dependency so it will get fetch data from API only one time when component render first time
useEffect(()=>{
// api call or fetch data
},[])
I am working on a ReactJS Web application and got stuck in a problem. Problem is I have an array of URLs of some JSON data and I want to fetch all these JSON data from server using "useSWR" hook (so that the fetched data gets cached as well). Now the problem is as per the rules we cannot use hooks inside any loop or block.
Example -
What I have - ["http://someapi/a.json", "http://someapi/b.json", "http://someapi/c.json"]
What I want to do - iterate over this array and call these urls using useSWR hook, so that I have a list of [ JSON ObjectA, JSON ObjectB, JSON ObjectC ]
Why I am trying to use "useSWR" because I know, this data will not gonna change for 24Hours and I want to cache these values.
Can anyone suggest me how can I iterate over the list of URLs and make a call to the server using useSWR hook? And is there's some other optimized approach to solve this problem? Any help or guidance is highly appreciated.
One of the option i think is to create React FetchComponent with url prop and use the useSWR hook inside.
Render components as number of urls.
Something like this:
["http://someapi/a.json", "http://someapi/b.json", "http://someapi/c.json"].map(url=><FetchComponent url={url}/>)
How to integrate mui-datatable with admin-on-rest?
Need the following options in the list view :
move around ordering of columns
show/hide columns
change the number of rows for display
print preview of table
Mui-datatable has these features. According to admin-on-rest documentation, we can use custom Datagrid. Can anyone explain how to do it?
Say you are making a custom-datagrid component 'MyIterator'. This component has to just make use two props that will 'auto-magically' be available to the child of 'List' component. One prop is ids and another is data.
The ids prop is an array of id of currently displayable data-items. And the data is an object containing the data for all the items displayable.
Something like this should do the part of making a custom-datagrid -
const MyIterator = ({ids, data}) => ids.map(id=><div key={id}><span>Label</span><span>{data[id].label}</span></div>)
Above example presumed the data-item object to have a property of 'label'.
And this is how a custom-datagrid can be made.
/*
Details :
I am looking for a way to implement table in such a way that
I can add or remove the data on click or selection of row.
Also can we use native js events in the material - ui
Also, if any library is there, please share as soon as possible.
*/
Map over the table row data and add a prop for this.handleEdit.bind(this, data.id) and this.handleRemove.bind(this, data.id). Then in those functions, use the id to make an api call to update or delete the row.