При использовании функции DrawerLayout
в этом случае должно быть только одно основное содержимое View
с ящиком View
- в этом случае ваш ListView
- после него. Использование DrawerLayout
любым другим способом приведет к неправильному, непредсказуемому поведению, часто препятствуя нормальному взаимодействию с другими элементами макета.
Учебник со ссылками на образец и документы можно найти на this страница разработчика .
Можно также получить судей в функциональные компоненты с небольшой инфраструктурой
import React, { useEffect, useRef } from 'react';
// Main functional, complex component
const Canvas = (props) => {
const canvasRef = useRef(null);
// Canvas State
const [canvasState, setCanvasState] = useState({
stage: null,
layer: null,
context: null,
canvas: null,
image: null
});
useEffect(() => {
canvasRef.current = canvasState;
props.getRef(canvasRef);
}, [canvasState]);
// Initialize canvas
useEffect(() => {
setupCanvas();
}, []);
// ... I'm using this for a Konva canvas with external controls ...
return (<div>...</div>);
}
// Toolbar which can do things to the canvas
const Toolbar = (props) => {
console.log("Toolbar", props.canvasRef)
// ...
}
// Parent which collects the ref from Canvas and passes to Toolbar
const CanvasView = (props) => {
const canvasRef = useRef(null);
return (
<Toolbar canvasRef={canvasRef} />
<Canvas getRef={ ref => canvasRef.current = ref.current } />
}