https://www.gravatar.com/avatar/62e8b71078f520590446ddf0979949dd?s=240&d=mp

分享RN最佳实践

Let's RNers have nothing hard to do

横向 瀑布流列表

需求 效果展示 源码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 import { StyleSheet, Text, TouchableOpacity, View } from "react-native"; import React, { useEffect, useRef, useState } from "react"; import HBImage from ".

用脚手架 制作一个RN库 放npm

脚手架 create-react-native-module 脚手架使用(顺利) 工具安装 1 2 npm install -g yarn npm install -g create-react-native-module 脚手架命令 1 create-react-native-module RemoteFont --object-class-name react-native-remote-font --object-class-name RemoteFontLoader --native-package-id com.yestin.font --platforms ios,android --github-account zyestin --author-name yestin --author-email zyestin@gmail.com --generate-example --example-react-native-template react-native@0.62 过程中发现,若不指定--example-react-native-template react-native@0.62,发现总有这样的报错日志 1 2 3 4 5 6 7 8 9 10 11 pod --version failure, aborting with broken example app Error while creating library module react-native-remote-font Error: Command failed with ENOENT: pod --version spawnSync pod ENOENT at Object.

远程字体的动态加载&应用

示例效果展示 切换到新字体,经过loading后,应用上新字体 切换到已加载过的字体,直接应用上 iOS Android 使用/Usage 封装后,如下这样使用,解耦的干干净净 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 import { StyleSheet, Text, TouchableOpacity, View } from "react-native"; import React, { useState } from "react"; import ArtText from "./ArtText"; const ArtTextDemo = () => { const [fontInfoIndex, setFontInfoIndex] = useState(0); return ( <View style={{ flex: 1, padding:100 }}> <TouchableOpacity style={{padding:10}} onPress={() => { setFontInfoIndex((fontInfoIndex + 1) % fontInfoList.

hugo + github pages usage

2023最新 hugo + github pages 使用方式 网上大多是hugo旧版的使用方式,有好几处明显差异的,不值得借鉴,反正我借鉴后出现各种莫名其妙问题 严格按照官方这两个链接,就不会出现问题: hugo quick start 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 hugo new site quickstart cd quickstart git init git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke echo "theme = 'ananke'" >> hugo.toml hugo server hugo new content posts/my-first-post.md open content/posts/my-first-post.md //然后进行修改 hugo server -D //可以编辑后, 在 http://localhost:1313/ 进行预览 hugo //生成web静态资源,以便下一步提交github时进行部署 Host on GitHub Pages 需要注意的地方: 请先尝试 hugo文档里提供的theme,即ananke,走通一遍流程 我就采坑了,使用了另一个theme,后面在 localhost 一直不出现 my-first-post.