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 issue for not rendering on object property state change #2461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions src/GiftedChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
}

export interface GiftedChatState<TMessage extends IMessage = IMessage> {
isInitialized: boolean
composerHeight?: number
messagesContainerHeight?: number | Animated.Value
typingDisabled: boolean
Expand Down Expand Up @@ -274,14 +273,15 @@ function GiftedChat<TMessage extends IMessage = IMessage>(
let _isTextInputWasFocused: boolean = false

const [state, setState] = useState<GiftedChatState>({
isInitialized: false, // initialization will calculate maxHeight before rendering the chat
composerHeight: minComposerHeight,
messagesContainerHeight: undefined,
typingDisabled: false,
text: undefined,
messages: undefined,
})

const [isInitialized,setIsInitialized] = useState(false);

useEffect(() => {
isMountedRef.current = true

Expand Down Expand Up @@ -604,11 +604,11 @@ function GiftedChat<TMessage extends IMessage = IMessage>(

setState({
...state,
isInitialized: true,
text: getTextFromProp(initialText),
composerHeight: minComposerHeight,
messagesContainerHeight: newMessagesContainerHeight,
})
});
setIsInitialized(true);
}

const onMainViewLayout = (e: LayoutChangeEvent) => {
Expand Down Expand Up @@ -681,7 +681,7 @@ function GiftedChat<TMessage extends IMessage = IMessage>(
[actionSheet, locale],
)

if (state.isInitialized === true) {
if (isInitialized === true) {
return (
<GiftedChatContext.Provider value={contextValues}>
<View testID={TEST_ID.WRAPPER} style={styles.wrapper}>
Expand Down