I have two elements that are supposed to appear depending on whether the condition is true or false but on one of them I need to use useRef hook but it doesn't work. Even though the element sometimes renders first, I still get the error Cannot set properties of null. I need to edit the second element's value when it renders with its reference but the code crashes so I can't do anything. Code looks like this:
inputRef.current.value="Some text"
{condition ? <SomeOtherComponent /> : <input type="text" ref={inputRef} />}
You have few options to fix that
value={'Some text'}.current.value.