-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Using the basic-flow example and adding a name to the state:
const initialState: State = {
count: 0,
name: 'john doe',
};And an action to set the name:
const actions = {
increment:
(): Action<State> =>
({ setState, getState }) => {
setState({
count: getState().count + 1,
});
},
setName:
(name: string): Action<State> =>
({ setState }) => {
setState({
name: name,
});
},
};And a simple input component to the CounterHook component:
const CounterHook = () => {
const [{ count, name }, { increment, setName }] = useCounter();
return (
<div>
<h3>With Hooks</h3>
<p>{count}</p>
<p>{name}</p>
<button onClick={increment}>+1</button>
<input value={name} onChange={e => setName(e.target.value)} />
</div>
);
};If text is added to the beginning, or middle of the name field, the first character will be correct, but the caret will jump to the end of the text after a single entry.
This is not the behaviour if I make a local state using React.useState
Here is a video of the behaviour:
Screen.Recording.2022-09-22.at.12.38.05.PM.mov
adhiljuvane
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working