Skip to content

Commit

Permalink
fix using valtio ref
Browse files Browse the repository at this point in the history
  • Loading branch information
RenaudRohlinger committed Feb 6, 2021
1 parent c2955d5 commit 6160d8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions packages/core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, VFC } from 'react';
import { editorContext } from '../../.';
import { getNameForEditorMaterial } from '../../helpers/shaderToMaterial';
import { editorState } from '../../state';
import { useProxy } from 'valtio';
import { ref, useProxy } from 'valtio';
import { IoEyeOutline } from 'react-icons/io5';
import { IoEyeOffOutline } from 'react-icons/io5';
import { IoImageOutline } from 'react-icons/io5';
Expand Down Expand Up @@ -66,15 +66,14 @@ export const LiMenu: VFC<LiMenuProps> = ({ type, program }) => {
const value = {
type,
open: true,
ref: ref(program),
isModif: false,
model: `urn:${name}.${type}`,
};
editorState.tabs[`urn:${name}.${type}`] = value;
editorState.activeMaterial = value;

editorContext.activeMaterial = value;
editorContext.activeMaterial.ref = program


editorState.showEditor = true;
editorState.diffMode = false;
editorState.obcMode = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const EditorTabs = () => {
}`}
>
{Object.entries(snapshot.tabs).map(([key, value]: any) => {
const material = editorContext.activeMaterial.ref.material;
const program = editorContext.activeMaterial.ref.program;
const material = value.ref.material;
const program = value.ref.program;
const name = getNameForEditorMaterial(material, program)

return (
Expand Down

0 comments on commit 6160d8b

Please sign in to comment.