1

通过按钮处理程序访问时,通过 useSelector (redux) 填充的变量显示 null 而不是实际值。当使用基于类的方法时,它工作正常:

import React from "react";

import { useSelector } from "react-redux";
import { Button } from "@sencha/ext-react-modern";

const LoadButton = () => {
  const viewer = useSelector((state) => state.bim._viewer);

  const handleSenchaBtn = () => {
    console.log("sencha button", viewer);
  };
  const handleHtmlBtn = () => {
    console.log("html button", viewer);
  };
  return (
    <>
      <button onClick={handleHtmlBtn}>Normal Button</button>
      <Button text="Sencha Button" ui="action" handler={handleSenchaBtn} />
    </>
  );
};

export default LoadButton;

按钮操作的控制台日志:

控制台日志

4

0 回答 0