Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the default value of a Material UI prop-function in React JS?

I'm working with React JS and I've imported from Material UI a component called (https://material-ui.com/api/table-pagination/) and I would like to modify the Default of labelDisplayedRows that now is like this:

({ from, to, count }) => ${from}-${to} of ${count}

I would like to edit the "of" of the output, but it's a function, and so i don't know how to do it. If it was a simple node like labelRowsPerPage I would modify it by writing

<TablePagination
                    labelRowsPerPage="text text text"
/>

How could I do it? Thank you in advance

like image 836
M_Lude Avatar asked May 28 '18 10:05

M_Lude


People also ask

How do I change the default value in material UI dropdown?

You can set the VALUE in the Select control as the state value. Don't forget, when handling the onChange event, that you will need to convert the event. target. value to string.

How do I change the default value in TextField material UI?

The MUI TextField can display a default value on render by using the defaultValue prop. This is useful if you don't need to externally get or set the TextField value, or if you are using a form. A form will automatically extract a TextField child components value on submit of the form.

How do I change the default value in React state?

To set a default value for an input element in React:Pass the default value as a parameter to the useState hook for controlled fields. Set the defaultValue prop on uncontrolled input fields.


1 Answers

Something like this:

<TablePagination labelDisplayedRows={({ from, to, count }) => `Displaying pages ${from}-${to} of total ${count} pages`}/>
like image 113
const314 Avatar answered Oct 12 '22 18:10

const314