How can i set a default value in InputEmoji , it is always the value set as " "
<InputEmoji value={text} onChange={setText} cleanOnEnter placeholder="Votre commentaire ici ..." onEnter={handleUpdateComment} />
the text variable contain a value for example "Hello there" but it didnt display in the input
did you get any solutions @louayyahyaoui
@louayyahyaoui bro, did you get this issue resolved, I am still having the same problem.
Sorry but i didnt get any solution yet
@farhadhabibi you need to use 'useRef', for example ` const emojiRef = useRef();
useEffect(() => {
emojiRef.current.value = YOUR_DEFAULT_DATA;
}, []);
return (
<InputEmoji ref={emojiRef} />
);
`
@PavelLazarchuk, thank you bro it helps me alot, could you please tell me why I should use 'useEffect' since I tried to make it without useEffect but it did not work?
Just use value from the useState hook and pass it to the value prop of the <InputEmoji/> component.
const App = () => {
const [message, setMessage] = useState<string>("default message");
return (
<InputEmoji value={message} />
);
}
P.S: I've tested this option. And when I tried to set the default message this way - it works fine.