Skip to content

React Input caret jumps to to the end when typing #270

@timuric

Description

@timuric

For some reason react input always jumps to the end of the field.
Try to type something, then change caret to anywhere else and type further.
Is Valtio doesn't work with controlled components or am I missing something?

import React from "react";
import { proxy, useSnapshot } from "valtio";

// create a base proxy
const state = proxy({
  text: ""
});

export default function App() {
  const { text } = useSnapshot(state);
  return (
    <input
      value={text}
      onChange={(e) => {
        state.text = e.target.value;
      }}
    />
  );
}

Live demo:
https://codesandbox.io/s/valtio-input-bug-el7l7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions