Skip to content

Commit

Permalink
refactor(progress): ♻️ remove sealed state
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Nov 9, 2020
1 parent 77bcf0e commit 555c857
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/progress/ProgressState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* to work with Reakit System
*/
import * as React from "react";
import { SealedInitialState, useSealedState } from "reakit-utils";

import { valueToPercent, isFunction, isNull } from "../utils";
import { valueToPercent, isNull } from "../utils";

export interface ProgressState {
/**
Expand Down Expand Up @@ -52,12 +51,10 @@ export type ProgressInitialState = Pick<
export type ProgressStateReturn = ProgressState & ProgressAction;

export function useProgressState(
initialState: SealedInitialState<ProgressInitialState> = {},
props: ProgressInitialState = {},
): ProgressStateReturn {
const { value: initialValue = 0, min = 0, max = 100 } = useSealedState(
initialState,
);
const [value, setValue] = React.useState(clampValue(initialValue, min, max));
const { value: defaultValue = 0, min = 0, max = 100 } = props;
const [value, setValue] = React.useState(clampValue(defaultValue, min, max));
const percent = isNull(value) ? null : valueToPercent(value, min, max);

return {
Expand Down

0 comments on commit 555c857

Please sign in to comment.