Short Answer: This approach in your scenario is alright. Just re-visit it when your scenario get change.
It's not an anti-pattern in your scenario. It will be consider an anti-pattern, if you are controlling behavior of child component through ref.
React suggest to avoid such anti-patterns as general advise to avoid edge cases where your component become unstable as it get controlled by different source of truth. But, in the scenario like yours where you are sure about why you are using it, it's fine.
For example, React advise not to populate state from props. This is true because then you have two source of truth and you need to sync them otherwise your component will not behave properly. But, If you are sure that, your props (specifically data) will not be going to change, it's no longer an anti-pattern because, you are now seeding state from props but then it continue to manage at state level only.
From React's doc on refs:
In the typical React dataflow, props are the only way that parent components interact with their children. To modify a child, you re-render it with new props.
Your first inclination may be to use refs to “make things happen” in your app. If this is the case, take a moment and think more critically about where state should be owned in the component hierarchy.
Refs were created to access the DOM in specific use cases (focus, text selection, media playback, third party libs, etc), but they shall be avoided when trying to make other components execute actions.
So of course you can have a React app that works while using refs to call child component method, but yes, it is very anti-pattern.
- Is it anti-pattern to call child component's method from Parent in react and why?
- Can't call child component method from parent component in React Native
- Call child component method from parent in react
- Call child method from parent class - React typescript
- How to call child component's method from a parent component in React
- Pass className from Parent to child and call css property issue - material ui react
- React call parent component method from child component method
- React - call a child components method from Parents ComponentDidmount()
- React - Call parent method from within child component
- How to call the parent method from child in react componentDidMount
- Call a method pass from parent component to child component in React
- ReactJS - Call parent method from child component and await response from parent
- Call method passed from redux in react from child to parent
- React call parent method from child of a child
- Typescript + React call parent method from child component
- Call child method from parent
- How can I call parent method in a child React component?
- Why do you need to import React multiple times in parent and child components?
- Call child component method from parent component in reactjs
- Why is child component not receiving updated value from parent in React Native?
- Passing event and props from child to parent in react
- React update state in parent from child components
- React 16: Call children's function from parent when using hooks and functional component
- React refs when parent and child are function components
- Rendering from a child to a parent using refs and portals in React
- How to call child component method from parent component in react?
- How to call parent function from child prop React 15.5.0
- React How to change state value from child to Parent using useState and useContext
- Parent - Child components and data responsibilities (should child call API?)
- React Dynamically download Components and get data from all child components
More Query from same tag
- Is secure to ignore the missing dependencies es-lint warning on react hooks?
- How to test React HOC function that is not passed into the wrapped component?
- Is there an efficient way to make this code DRY?
- .map() method using prior state in React
- show the seats from an object array Reactjs
- MUI Autocomplete, scroll with keyboard need highlight
- How to get textbox values on button click in React?
- React with Typescript:Unable to pass function prop to child component
- How do I display data created by SunEditor in a ReactJS app
- When using webpack to compile React it returns Unexpected token (
- How do I get back the generated filename after uploading to Cloudinary widget in ReactJS?
- Common Error Handling in React Redux Application
- Radio buttons not selecting React.js
- Get currencies from countries list with lodash/fp
- Uncaught (in promise) TypeError: Cannot read property 'red' of null
- react-photo-gallery don't change photos via state
- Material UI - How to add onChange method to pre-made components?
- React hooks rendering component before useEffect finishes
- How to change fontStyle and border color of VictoryTooltip
- How can I pass Interface to the child component in Typescript React application
- Error using useeffect and useref TypeError: Cannot read property 'getBoundingClientRect' of null
- How to reset cache from only one specific query
- Word Document Cannot find module or it's corresponding type declarations
- No overload matches this call Error while using css-in-js in Typescript, Webpack, React Project
- React js read data after loading
- Higher Order componnt does not dilver InputList
- How to avoid mutating state when updating a property
- How to fix the error TypeError: Cannot read property 'map' of undefined
- Firebase Admin Failed to determine project ID