question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problematic behavior when trying to implement a Form

See original GitHub issue

Hello, I am trying to implement a simple login form / view, here’s the view

const Login = module.exports = (state, actions) => <div key='login'>
    <h2>Login</h2>

    <FormInput label='Username' value={state.username} action={(value)=>actions.updateField({field: 'username', value}) } />
    <FormInput label='Password' value={state.password} action={(value)=>actions.updateField({field: 'password', value}) } />
    <button class='btn btn-primary' onclick={()=>actions.login()}>Ok</button>
</div>

and the FormInput component:

const FormInput = module.exports = ({label, value, action}) => <div class="form-group">
    <label class="form-label" for="{label}">{label}</label>
    <input class="form-input" type="text" id="{label}" 
        placeholder={label} value={value} 
        onkeyup={e => action(e.target.value)}
    />
</div>

(let’s ignore for now the fact that the password is a simple text input, it doesn’t matter for my question).

Now, I have the password and username on state and a corresponding action to update them, something like this:

var state = {
    auth: {
        token: null,
        username: null,
        password: null
    },
...

and

const reducers = module.exports = {
    location: location.actions, 
    auth: {
        updateField: ({field, value}) => state => {
            return {
                [field]: value
            }
        },

        login: () => state => {
            console.log("LOGIN", state);
        }

    }, 
...

I think this is a rather typical setup. The problem is that when I am writing on the textboxes I experience too much lag until the characters are actually displayed on the input - also, if I write too fast some characters are actually missing … For example if I write 123123123123123 really quick I’ll get something like this in the input: 12312322112. The problem, of course is that propagating the state for every keyup is too expensive and, in react is solved with local state. How can this problem be solved in hyperapp? Is there a technique I don’t know – the form is really not usable.

TIA

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
elisherercommented, Jun 25, 2018

I recommend trying a new library I wrote: hyperapp-forms

1reaction
spapascommented, Feb 16, 2018

Thank you very much for all the answers !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Identify and Define Problem and Replacement Behaviors
The first step in the FBA process is to identify and define the problem behavior (also referred to as the target behavior) and...
Read more >
What is a problem behavior? Common Forms of Problem ...
Any form of attention can be desirable - even stern looks, reprimands, and restraint. “There's no such thing as bad press.”
Read more >
Problem Behavior: Symptoms, Causes, Treatments and More
Problem behavior can have many symptoms, including but not limited to: abuse of alcohol or drugs; agitation; angry, defiant behaviors ...
Read more >
Functional Assessment of Problem Behavior: Dispelling Myths ...
Implementation Obstacle 5: Functional Analyses Can't Be Used for Dangerous Problem Behavior. The importance of creating analytic contexts that are safe for ...
Read more >
Complete Guide to Managing Behavior Problems
Learn how to improve the parent-child relationship when it becomes strained with CMI's Parents Guide to Problem Behavior.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found