This might be a noob react question (still learning), I have this constant:
const data = {
first_name: "John",
last_name: "smith",
employee: "Google"
};
That I pass to another function. This works but I want to move it to own file to make it more generic. If I move it to person-data.js:
import React, { useEffect } from "react";
const PersonData = props => {
const data = {
first_name: "John",
last_name: "smith",
employee: "Google"
};
return (
{data}
);
};
export default PersonData;
and in my main component:
import person from '../person-data'
.....
// temp to test
const data = {
first_name: "John",
last_name: "smith",
employee: "Google"
};
.....
somefunction(person) // doesnt work
somefunction(data) // works
it no longer works, the reason I want to move it is so I can use props to pass the info dynamically. Is this even a good way to do this?