mirror of
https://github.com/zoriya/yoshiki.git
synced 2025-12-05 22:56:14 +00:00
Fix insertion effect for react native
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yoshiki",
|
||||
"version": "1.2.13",
|
||||
"version": "1.2.14",
|
||||
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/zoriya)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -20,10 +20,10 @@ import {
|
||||
processStyleListWithChild,
|
||||
assignChilds,
|
||||
} from "../type";
|
||||
import { isBreakpoints } from "../utils";
|
||||
import { isBreakpoints, useForceRerender } from "../utils";
|
||||
import { shorthandsFn } from "../shorthands";
|
||||
import { StyleFunc, NativeCssFunc, EnhancedStyle } from "./type";
|
||||
import { useReducer, useRef } from "react";
|
||||
import { useRef } from "react";
|
||||
|
||||
const useBreakpoint = (): number => {
|
||||
const { width } = useWindowDimensions();
|
||||
@@ -61,10 +61,6 @@ const propertyMapper = (
|
||||
return [[key, value]];
|
||||
};
|
||||
|
||||
const useForceRerender = () => {
|
||||
return useReducer((x) => x + 1, 0)[1];
|
||||
};
|
||||
|
||||
type State = EnhancedStyle<ViewStyle | TextStyle | ImageStyle> | undefined;
|
||||
|
||||
export const useYoshiki = (_?: string) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useYoshiki = (prefixKey?: string) => {
|
||||
|
||||
useInsertionEffect(() => {
|
||||
registry.flushToBrowser();
|
||||
}, [registry]);
|
||||
});
|
||||
|
||||
const css: NativeCssFunc = (cssList, leftOvers) => {
|
||||
const [css, parentKeys] = processStyleListWithoutChild(cssList);
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
//
|
||||
|
||||
import { useReducer } from "react";
|
||||
import { breakpoints } from "./theme";
|
||||
import { Breakpoints, processStyleList, StyleList, YoshikiStyle } from "./type";
|
||||
|
||||
export const useForceRerender = () => {
|
||||
return useReducer((x) => x + 1, 0)[1];
|
||||
};
|
||||
|
||||
export const isBreakpoints = <T>(value: unknown): value is Breakpoints<T> => {
|
||||
if (typeof value !== "object" || !value) return false;
|
||||
for (const v of Object.keys(value)) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
processStyleListWithoutChild,
|
||||
WithChild,
|
||||
} from "../type";
|
||||
import { forceBreakpoint, isBreakpoints } from "../utils";
|
||||
import { forceBreakpoint, isBreakpoints, useForceRerender } from "../utils";
|
||||
import { StyleRegistry, useStyleRegistry } from "./registry";
|
||||
import { shorthandsFn } from "../shorthands";
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ export class StyleRegistry {
|
||||
if (!this.styleElement) {
|
||||
this.hydrate();
|
||||
}
|
||||
// Dont recompute css if no new rules was added.
|
||||
if (!this.rules.length) return;
|
||||
|
||||
const [css] = this.flushToStyleString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user