nlkitai / nlux

The π—£π—Όπ˜„π—²π—Ώπ—³π˜‚π—Ή Conversational AI JavaScript Library πŸ’¬ β€”Β UI for any LLM, supporting LangChain / HuggingFace / Vercel AI, and more 🧑 React, Next.js, and plain JavaScript ⭐️
https://docs.nlkit.com/nlux
Other
943 stars 48 forks source link

Refactor AiChat useEffect hook #42

Closed divyeshradadiya closed 3 months ago

divyeshradadiya commented 3 months ago

1) Renamed the inner function to updateAiChatProps for clarity and readability. 2)Moved the call to handleNewPropsReceived inside the updateAiChatProps function to encapsulate the logic for updating the AI chat props. 3) Ensured that the update of AI chat props is only performed if isUseEffectCancelled is false, new props are available, and the AI chat instance (aiChat.current) exists. 4)Updated the useEffect dependency array to include props and currentProps for proper dependency tracking.

salmenus commented 3 months ago

@divyeshradadiya Thank you for your pull request. Merging.

FYI:

I'm in the process of re-factoring / re-writing the entire React part of the project. New code here: https://github.com/nluxai/nlux/pull/43 ( not merged yet ).