The state is being mutated directly in the parent's onChange and hence your useEffect in ReadOnly component is not being triggered.

Update your onChange

const onChange = (e: IChangeEvent<any>) => {
    setFormDataAndIncludings(prev => ({
            ...prev ,
            queryData : [
                e.formData,
                ...prev.queryData.slice(0,1)
            ]
        }))

    //const newFormDataAndIncludings = { ...formDataAndIncludings };
    //newFormDataAndIncludings.queryData[0] = e.formData;
    //setFormDataAndIncludings(newFormDataAndIncludings);
};

Provide useEffect dependency as usual

React.useEffect(() => {
        setValue(firstName());
    }, [formContext]);
Answer from Guru Hadadi on Stack Overflow
🌐
Medium
omarshishani.medium.com › why-useeffect-is-not-updating-when-props-change-c2e603a7e98b
Why useEffect is Not Updating When props Change 👻 | by Omar Shishani | Medium
January 9, 2021 - Why won’t my component register the changed values of props??? The answer for me was that I was not passing in props to useEffect as a dependency. It didn't even occur to me that it was useEffect which was causing the problem. In many cases, I use useEffect like componentDidMount. However, I only want it to run once, because I need to update state, and if useEffect runs on each state update it will cause an infinite loop.
🌐
Reddit
reddit.com › r/reactjs › react component prop change not triggering useeffect() when inside another library
r/reactjs on Reddit: React component prop change not triggering useEffect() when inside another library
May 26, 2021 -

First off, I am painfully aware this is not an ideal scenario. I have an app using OpenUI5 with some React functional components/hooks inside:

private _myReactWindow = window["studioStepComponents"];
private _myReactView;
private someFunction(someNewValue) {
    this._myReactView.someProp = someNewValue
}
private someRenderFunction() {
    this._myReactView = this._myReactWindow.createElement(this._myReactWindow.MyReactComponent,
    {
        someProp: this.someValue
    });
} 

createElement is working fine and in "someFunction" I can see the correct values for this._myReactView.someProp, even after setting it to a different value, but the useEffect() hook is not triggering on the React side. Is there any way I can get it to pick up the change? I realize these are different frameworks with different bindings but with the value changing I still would have thought React would see the prop change.

🌐
GitHub
github.com › tannerlinsley › react-query › issues › 2628
Bug: useEffect not triggering on [deps] change · Issue #2628 · TanStack/query
September 2, 2021 - The problem is that one state change gets swallowed by useEffect. It can be seen if you click on a button and watch the console, useEffect is not triggered even though UI updates correctly aka rerender is triggered. I have found that the issue is caused by line 60 in the same file. if that line is commented out, then useEffect triggers properly when button is clicked.
Author   Tosheen
🌐
DhiWise
dhiwise.com › post › how-to-fix-useeffect-not-triggering-in-your-react-project
Reasons Why UseEffect Is Not Triggering In Your React App
May 29, 2024 - Sometimes developers encounter a situation where the useEffect not triggering as expected. This can be due to several reasons, such as an incorrect dependency array or the absence of dependencies that should trigger the effect.
🌐
CopyProgramming
copyprogramming.com › howto › react-useeffect-is-not-triggering-after-prop-change
UseEffect Hook Not Triggering After Change in Prop - Javascript
May 31, 2023 - ReactJS: useEffect is not run when the url changes, This tells React that your effect doesn’t depend on any values from props or state, so it never needs to re-run. If you want to run the effect on every render, you can leave off the second argument.
🌐
Stack Overflow
stackoverflow.com › questions › 67697134 › react-component-prop-change-not-triggering-useeffect-when-inside-another-libra
reactjs - React component prop change not triggering useEffect() when inside another library - Stack Overflow
createElement is working fine and in "someFunction" I can see the correct values for this._myReactView.someProp, even after setting it to a different value, but the useEffect() hook is not triggering on the React side. Is there any way I can get it to pick up the change? I realize these are different frameworks with different bindings but with the value changing I still would have thought React would see the prop change.
Find elsewhere
🌐
React
react.dev › learn › you-might-not-need-an-effect
You Might Not Need an Effect – React
If your Effect also immediately updates the state, this restarts the whole process from scratch! To avoid the unnecessary render passes, transform all the data at the top level of your components. That code will automatically re-run whenever ...
🌐
Stack Overflow
stackoverflow.com › questions › 71974602 › react-useeffect-is-not-triggering-after-prop-change
React useEffect is not triggering after prop change
April 22, 2022 - As shown in the picture enter image ... and it means that the filteredUsers state variable keep containing a user object instead of an array of users that should have if the useEffect would have triggered....
🌐
Today I Learned
til.hashrocket.com › posts › z1xzaupgpd-run-side-effect-when-a-prop-changes-whooks
Run side effect when a prop changes w/Hooks - Today I Learned
May 25, 2022 - useEffect(() => console.log('value changed!'), [props.isOpen]); Now, you will see "value changed!" both on the first render and everytime isOpen changes. Reminder: React Hooks are for functional components not class components. Check out the hooks api here Tweet ·
🌐
React
react.dev › reference › react › useEffect
useEffect – React
However, you can express that you ... to changes even though it is called from inside an Effect. Declare an Effect Event with the useEffectEvent Hook, and move the code reading shoppingCart inside of it: ... Effect Events are not reactive and must always be omitted from dependencies of your Effect. This is what lets you put non-reactive code (where you can read the latest value of some props and state) ...
🌐
Linguine Code
linguinecode.com › home › blog › react useeffect hook with code examples
React useEffect hook with code examples
July 16, 2020 - ... This is the normal behavior that you would see in a traditional React class component. By running an empty array [] as a second argument, you’re letting React know that your useEffect function doesn’t depend on any values from props or state.
🌐
Reddit
reddit.com › r/reactjs › how to fix the issue of useeffect not triggering on route change even after feeding in params object's property as dependency?
r/reactjs on Reddit: How to fix the issue of UseEffect not triggering on route change even after feeding in Params Object's property as dependency?
September 23, 2022 -

Here's my App.js component

App.js

function App() {
  return (
    <GithubProvider>
      <AlertProvider>
        <Router>
          <div className="flex flex-col justify-between h-screen">

            <Navbar />

              <main className='container mx-auto px-3 pb-12'>
                <Alert />

                <Routes>
                <Route path="/" element={<Home />} />

                <Route path="/about" element={<About />} />
                <Route path="/user/:login" element={<User />} /> {/* ISSUE */}

                <Route path="*" element={<NotFound />} />

              </Routes>


              </main>

            <Footer />

          </div>
        </Router>
      </AlertProvider>
    </GithubProvider>
   
  );
}

The route change to the user component happens in Home Component, I search for a github profile,
a lift of profiles are displayed, I click on the visit profile button on the profile card, which Links me to User component

UserItem.js:

import { Link } from 'react-router-dom'
import PropTypes from 'prop-types'


const UserItem = ({user: {login, avatar_url}}) => {

    return (
        <div className='card shadow-md compact side bg-base-600'>
        <div className='flex-row items-center space-x-4 card-body'>
          <div>
            <div className='avatar'>
              <div className='rounded-full shadow w-14 h-14'>
                <img src={avatar_url} alt='Profile' />
              </div>
            </div>
          </div>
          <div>
            <h2 className='card-title'>{login}</h2>
            <Link
              className='text-base-content text-opacity-60'
              to={`/user/${login}`}
            >
              Visit Profile {/* TRIGGERING HERE!!!!!!!!!!! */}
            </Link>
          </div>
        </div>
      </div>
    )
}


UserItem.propTypes = {
    user: PropTypes.object.isRequired,
}

export default UserItem;

My user Component where the function getUser needs to be triggered->
The function getUsers works fine as when i used it outside an useEffect, it did give me the right response from the fetch call inside.

User.js

import React, { useEffect, useContext } from 'react'
import {FaCodepen, FaStore, FaUserFriends, FaUsers} from 'react-icons/fa'
import { Link } from 'react-router-dom'
import GithubContext from '../context/github/GithubContext'
import { useParams } from 'react-router-dom'
import Spinner from '../components/layout/Spinner'
import RepoList from '../components/repos/RepoList'





export const User = () => {

    const params = useParams()
    
    
    const { getUser, user, loading, getUserRepos, repos } =
    useContext(GithubContext)
    
    console.log("params", params, "login", params.login) // WORKS FINE
    
    
    useEffect ( () => {
        console.log("use-effect", getUser, "", params.login)
        getUser(params.login)
        getUserRepos(params.login)

    },[params.login]) // DOESNT TRIGGER WITH [] or [params.login]

    console.log( "user-check",user) // user object empty
    
    const {
        name,
        type,
        avatar_url,
        location,
        bio,
        blog,
        twitter_username,
        login,
        html_url,
        followers,
        following,
        public_repos,
        public_gists,
        hireable,
      } = user


      console.log("YES THIS PAGE") // Here I was checking whether page is being mounted and YES it is being mounted 


    const websiteUrl = blog?.startsWith('http') ? blog : 'https://' + blog


    if(loading){
        return <Spinner />
    }



  return (<> TYPICAL INFORMATION DISPLAY UI </>)
}
🌐
freeCodeCamp
freecodecamp.org › news › most-common-react-useeffect-problems-and-how-to-fix-them
React.useEffect Hook – Common Problems and How to Fix Them
October 14, 2021 - While it is true that we are passing an object with the same key and value, it is not the same object exactly. We are actually creating a new object every time we re-render our Component. Then we pass the new object as an argument to our useUser hook. Inside, useEffect compares the two objects, and since they have a different reference, it once again fetches the users and sets the new user object to the state. The state updates then triggers a re-render in the component.