Skip to content

useTypedController #6

Open
Open

Description

@lionskape

Describe the solution you'd like
replace such lines:

import { useTypedController } from '@hookform/strictly-typed';
...
const TypedController = useTypedController<DealPlacementPositionValue>({ control });
...
<TypedController ... />
...

with

import { Controller } from 'react-hook-form';
...
<Controller contol={control} render={({field})} ... />
...

Additional context
We can create codemod for TypedController (from @hookform/strictly-typed package). It was working very similar way as a new Controller.

TODO:
Handle new structure of render properties

Activity

  1. jorisre commented on Mar 15, 2021

    @jorisre
    Member

    Thanks @lionskape Do you have more example to migrate ? I think it's hard to handle all uses cases.
    We can use useController too in replacement of useTypedController

    @bluebill1049 what's your thoughts ?

  2. bluebill1049 commented on Mar 15, 2021

    @bluebill1049
    Member

    I am not codemod expert, I would assume migrate useTypedController would be tricky due to the input name itself is an array.

  3. lionskape commented on Mar 15, 2021

    @lionskape
    Author

    @jorisre Unfortunately, useController is not a replacement of useTypedController. useTypedController creates a component, but useController creates an object.

    @bluebill1049 can you explain, what is a problem with name? Seems like we have to change array notation to the template string.

    By the way - it would be very useful, because useTypedController will no longer be maintained react-hook-form/strictly-typed#29 (comment)

  4. bluebill1049 commented on Mar 15, 2021

    @bluebill1049
    Member

    @bluebill1049 can you explain, what is a problem with name? Seems like we have to change array notation to the template string.

    That's the problem which you have described, I think for any exiting useTypedControlled, you will have to manually convert to just useController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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