Replies: 1 comment
-
I’d your columns are never changing from state or props, then yes, do it outside of your component.
Tanner Linsley
…On Mar 25, 2022, 3:32 AM -0600, Sebastian Obentheuer ***@***.***>, wrote:
Dear @tannerlinsley,
first of all, let me thank you for being one of the greatest open source contributors in the known universe.
Secondly, whenever I should memoize or useCallback() something in the Tanstack, can I just use a const variable (global to my file) outside of my functional component block (if I only need it once for all components of that type)? If no, why?
Thank you so much.
Example:
import { useTable } from 'react-table'
const columns =
() => [
{
Header: 'Column 1',
accessor: 'col1', // accessor is the "key" in the data
},
{
Header: 'Column 2',
accessor: 'col2',
},
]
function App() {
const data = React.useMemo(
() => [
{
col1: 'Hello',
col2: 'World',
},
{
col1: 'react-table',
col2: 'rocks',
},
{
col1: 'whatever',
col2: 'you want',
},
],
[]
)
// ...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Dear @tannerlinsley,
first of all, let me thank you for being one of the greatest open source contributors in the known universe.
Secondly, whenever I should memoize or useCallback() something in the Tanstack, can I just use a const variable (global to my file) outside of my functional component block (if I only need it once for all components of that type)? If no, why?
Thank you so much.
Example:
Beta Was this translation helpful? Give feedback.
All reactions