Skip to content

How to use React Hooks? #257

@barriehadfield

Description

@barriehadfield

React Hooks are becoming more prevalent and supported by React >16.8.0 onward.

After much experimentation, I have mot found a way to work with hooks using react-dart.

In the example below useHistory() is a hook in the latest version of ReactRouter.

import { useHistory } from "react-router-dom";

function HomeButton() {
  const history = useHistory();

  function handleClick() {
    history.push("/home");
  }

  return (
    <button type="button" onClick={handleClick}>
      Go home
    </button>
  );
}

How would it be possible to implement the code above using react-dart?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions