Answer the question
In order to leave comments, you need to log in
How to work with arrays of data objects coming from the back?
Let's say we go to the settings page (there are a lot of them).
1 setting contains the following information:
settings_one: {
[
'type' => 'setting_name_1',
'switch' => true,
'input' => 5,
'other_input' => NULL,
'text' => 'Описание настройки 1',
],
[
'type' => 'setting_name_2',
'switch' => false,
'input' => 3,
'other_input' => NULL,
'text' => 'Описание настройки 2',
],
// ..........................
}
const [settings, setSettings] = useState(null);
const memoizedGetSettings = useCallback(async () => {
const response = await getSettings();
setSettings(response.settings);
}, []);
useEffect(() => {
memoizedGetSettings();
}, [memoizedGetSettings]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question