Topic: how to get MDBInput value?

Ominous Vibes priority asked 2 years ago

Title says it all. Is there any getValue event on mdb5? instead of the onChanged event.

Krzysztof Wilk staff answered 2 years ago


There are only two ways to get the input value.

Uncontrolled input - the only way to get the value is to use an onChange event.

import React, { useState } from "react";
import { MDBInput } from "mdb-react-ui-kit";

function App() {
  return <MDBInput onChange={(e) => console.log(} />;

export default App;

Controlled input - you can use an useState hook to achieve that.

import React, { useState, useEffect } from 'react';
import { MDBInput } from 'mdb-react-ui-kit';

function App() {
  const [inputValue, setInputValue] = useState('');

  useEffect(() => {
  }, [inputValue]);

  return (
    <MDBInput value={inputValue} onChange={(e) => setInputValue(} />

export default App;

The getValue method is only used in the MDBSelect component due to its complicated structure.

Keep coding!

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB React
  • MDB Version: MDB5 1.4.0
  • Device: Windows
  • Browser: Opera GX
  • OS: 64
  • Provided sample code: No
  • Provided link: No