Is there some way to get this "name" value after clicking on li item and set it to selectedBranch state using ref?
const [selectedBranch, setSelectedBranch] = useState(null);
const selectRef = useRef();
const selectDeliveryBranch = () => {};
return (
<li
onClick={selectDeliveryBranch}
>
<p ref={selectRef}>{props.name}</p>
</li>
>Solution :
You do not want to use ref to do this, instead simply create a callback:
return <li onClick={()=>setSelectedBranch(props.name)}>
<p>props.name</p>
</li>
No ref needed