Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tsx erros in LabelContainer #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions LabelContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import React, { PureComponent } from 'react';
import { View } from 'react-native';
import React, { useState, ReactNode } from 'react';
import { StyleProp, View, ViewProps } from 'react-native';

class LabelContainer extends PureComponent {
export interface Props<T> {
renderContent: (value: T) => ReactNode;
}

state = {
value: Number.NaN,
};

setValue = value => {
this.setState({ value });
}
const LabelContainer = <T extends unknown>({
renderContent,
...restProps
}: Props<T> & StyleProp<ViewProps>) => {
const [value, setValue] = useState<T | typeof Number.NaN>(Number.NaN);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setValue is a method which is called on this component's ref here.
It can't be a state variable.
The reason is described here.


render() {
const { renderContent, ...restProps } = this.props;
const { value } = this.state;
return (
<View {...restProps}>
{renderContent(value)}
</View>
);
}
}
return <View {...restProps}>{renderContent(value)}</View>;
};

export default LabelContainer;
2 changes: 1 addition & 1 deletion hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const useThumbFollower = (
) => {
const xRef = useRef(new Animated.Value(0));
const widthRef = useRef(0);
const contentContainerRef = useRef<FollowerContainer | null>(null);
const contentContainerRef = useRef();

const {current: x} = xRef;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-range-slider",
"version": "2.2.2",
"version": "2.2.3",
"author": "Tigran Sahakyan <mail.of.tigran@gmail.com>",
"description": "A highly optimized pure JS implementation of Range Slider for React Native",
"homepage": "https://github.com/githuboftigran/rn-range-slider",
Expand Down