I try to access some refs in my component. But I have this error in the console. withRouter.js:44 Warning: Stateless function components cannot be given refs (See ref "pseudo" in FormInputText created by RegisterForm). Attempts to access this ref will fail.
Here is my component:
class RegisterForm extends React.Component { render() { return ( <form action=""> <FormInputText ref="pseudo" type="text" defaultValue="pseudo"/> <input type="button" onClick={()=>console.log(this.refs);} value="REGISTER"/> </form> ); } }
Plus when I click on the button I got Object {pseudo: null}
in the console. I would expect an object instead null
.
I am not sure to understand why this is not working. Note that my react tree uses mobx-react
.